Submission #146658

#TimeUsernameProblemLanguageResultExecution timeMemory
146658pichulia분수 (KPI13_fractions)C++11
0 / 1
1067 ms504 KiB
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { long long int a,b,c,d; long long int k; scanf("%lld %lld %lld %lld",&a,&b,&c,&d); long long int x,y; long long int p,q; k = a/b; y=1; while(1) { p=d+(a*y/b)*d; q=c*y; if(p<q)break; y += (p-q)/(c-k*d)+1; } x = a*y/b+1; printf("%lld %lld\n",x,y); } }

Compilation message (stderr)

fractions.cpp: In function 'int main()':
fractions.cpp:5:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&t);
     ~~~~~^~~~~~~~~
fractions.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...