# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146658 | pichulia | 분수 (KPI13_fractions) | C++11 | 1067 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |