Submission #928760
Source Code Expand
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C) ((B) <= (A) && (A) <= (C))
typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;
#define AIN(A, B, C) assert(IN(A, B, C))
//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;
int main()
{
int n;
LL T, A;
LL x, y;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%lld %lld", &x, &y);
if (i == 1) {
T = x;
A = y;
continue;
}
if (x * A >= T * y) {
LL D = (x % y) * (A % y);
D %= y;
for (int j = 0; j <= 1000; j++) {
LL Z = D + j * x;
if (Z % y == 0) {
LL q = j;
LL p = x *((A + q) / y) - T;
T += p;
A += q;
break;
}
}
}
else {
LL D = ((T % x) * (y % x)) % x;
for (int j = 0; j <= 1000; j++) {
LL Z = j * y + x - D;
if (Z % x == 0) {
LL p = j;
LL q = y * ((p + T) / x) - A;
T += p;
A += q;
break;
}
}
}
}
printf("%lld\n", T + A);
return 0;
}
Submission Info
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:53:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:55:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld", &x, &y);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_000.txt, 0_001.txt, 0_002.txt |
All |
0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt |
Case Name |
Status |
Exec Time |
Memory |
0_000.txt |
AC |
3 ms |
256 KB |
0_001.txt |
AC |
3 ms |
256 KB |
0_002.txt |
AC |
3 ms |
256 KB |
1_003.txt |
AC |
3 ms |
256 KB |
1_004.txt |
AC |
3 ms |
256 KB |
1_005.txt |
AC |
3 ms |
256 KB |
1_006.txt |
AC |
3 ms |
256 KB |
1_007.txt |
AC |
3 ms |
256 KB |
1_008.txt |
WA |
3 ms |
256 KB |
1_009.txt |
WA |
3 ms |
256 KB |
1_010.txt |
WA |
3 ms |
256 KB |
1_011.txt |
AC |
3 ms |
256 KB |
1_012.txt |
AC |
3 ms |
256 KB |
1_013.txt |
WA |
3 ms |
384 KB |
1_014.txt |
WA |
8 ms |
256 KB |