Submission #2830038


Source Code Expand

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

//m<=n
void loop(int64 m,int d,int up,int64 n,int *p,int64 *resM,int *resD){
  if(m*p[0]>n){
    if(*resD<d){
      *resM=m;
      *resD=d;
    } else if(*resD==d){
      *resM=MIN(*resM,m);
    }
    return;
  }
  int c;
  int64 mm;
  for(mm=m*p[0],c=1;mm<=n && c<=up;mm*=p[0],c++){
    loop(mm,d*(c+1),c,n,p+1,resM,resD);
  }  
  return;
}

void run(void){
  int q;
  scanf("%d",&q);
  while(q--){
    int64 n;
    scanf("%lld",&n);
    if(n==1){
      printf("1 1\n");
      continue;
    }
    int p[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
    int d=1;
    int64 m=1;
    loop(1,1,60,n,p,&m,&d);
    printf("%d %lld\n",d,m);
  }
}

int main(void){
  run();
  return 0;
}

Submission Info

Submission Time
Task D - 2016
User sansen
Language C (GCC 5.4.1)
Score 100
Code Size 922 Byte
Status AC
Exec Time 138 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘run’:
./Main.c:32:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&q);
   ^
./Main.c:35:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ^

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 8 / 8 34 / 34 58 / 58
Status
AC × 4
AC × 8
AC × 12
AC × 16
Set Name Test Cases
Sample sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt
Subtask1 sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, sub1_1.txt, sub1_2.txt, sub1_3.txt, sub1_4.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, sub1_1.txt, sub1_2.txt, sub1_3.txt, sub1_4.txt, sub2_1.txt, sub2_2.txt, sub2_3.txt, sub2_4.txt
Subtask3 sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, sub1_1.txt, sub1_2.txt, sub1_3.txt, sub1_4.txt, sub2_1.txt, sub2_2.txt, sub2_3.txt, sub2_4.txt, sub3_1.txt, sub3_2.txt, sub3_3.txt, sub3_4.txt
Case Name Status Exec Time Memory
sample_1.txt AC 1 ms 128 KB
sample_2.txt AC 1 ms 128 KB
sample_3.txt AC 1 ms 128 KB
sample_4.txt AC 1 ms 128 KB
sub1_1.txt AC 1 ms 128 KB
sub1_2.txt AC 1 ms 128 KB
sub1_3.txt AC 1 ms 128 KB
sub1_4.txt AC 1 ms 128 KB
sub2_1.txt AC 1 ms 128 KB
sub2_2.txt AC 1 ms 128 KB
sub2_3.txt AC 1 ms 128 KB
sub2_4.txt AC 1 ms 128 KB
sub3_1.txt AC 9 ms 128 KB
sub3_2.txt AC 9 ms 128 KB
sub3_3.txt AC 136 ms 128 KB
sub3_4.txt AC 138 ms 128 KB