Submission #928327


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;
		}

		LL D = x * A - T * y;
		if (D >= 0) {
			for (int j = 0; j <= 1000; j++) {
				LL Z = D + j * x;
				if (Z % y == 0) {
					LL q = j;
					LL p = Z / y;
					T += p;
					A += q;
					break;
				}
			}

		}
		else {
			for (int j = 0; j <= 1000; j++) {
				LL Z = j * y - D;
				if (Z % x == 0) {
					LL q = Z / x;
					LL p = j;
					T += p;
					A += q;
					break;
				}
			}
		}
	}

	printf("%lld\n", T + A);
	return 0;
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User dragoon
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1768 Byte
Status WA
Exec Time 8 ms
Memory 384 KB

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
AC × 3
AC × 13
WA × 2
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 2 ms 256 KB
0_001.txt AC 2 ms 256 KB
0_002.txt AC 2 ms 256 KB
1_003.txt AC 2 ms 256 KB
1_004.txt AC 3 ms 256 KB
1_005.txt AC 2 ms 256 KB
1_006.txt AC 2 ms 256 KB
1_007.txt AC 2 ms 256 KB
1_008.txt AC 5 ms 384 KB
1_009.txt WA 2 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 AC 3 ms 256 KB
1_014.txt AC 8 ms 256 KB