Submission #1836634
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))
#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;
const int MAX = 100100;
int A[MAX];
int gcd(int a, int b)
{
if (b == 0) return a;
return gcd(b, a%b);
}
string f = "First";
string s = "Second";
void F()
{
cout<<f<<endl;
exit(0);
}
void S()
{
cout<<s<<endl;
exit(0);
}
int main()
{
//freopen("in.txt", "r", stdin);
//ios::sync_with_stdio(false); cin.tie(0);
int n;
scanf("%d", &n);
FOR (i, 0, n)
{
scanf("%d", &A[i]);
}
while(true)
{
int p = 0;
int np = 0;
int ind = -1;
FOR (i, 0, n)
{
if (A[i] % 2 == 0) p++;
else np++, ind = i;
}
if (p % 2 == 1) F();
if (np == 1)
{
if (A[ind] == 1) S();
A[ind]--;
int g = 0;
FOR (i, 0, n)
{
g = gcd(g, A[i]);
}
FOR (i, 0, n)
{
A[i] /= g;
}
swap(f, s);
continue;
}
S();
}
}
Submission Info
Submission Time |
|
Task |
D - Decrementing |
User |
vjudge3 |
Language |
C++14 (GCC 5.4.1) |
Score |
1000 |
Code Size |
1329 Byte |
Status |
AC |
Exec Time |
42 ms |
Memory |
640 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:54:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:57:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &A[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
1000 / 1000 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample1.txt, sample2.txt, sample3.txt |
All |
sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name |
Status |
Exec Time |
Memory |
in1.txt |
AC |
12 ms |
640 KB |
in10.txt |
AC |
12 ms |
640 KB |
in11.txt |
AC |
22 ms |
640 KB |
in12.txt |
AC |
13 ms |
640 KB |
in13.txt |
AC |
19 ms |
640 KB |
in14.txt |
AC |
37 ms |
640 KB |
in15.txt |
AC |
18 ms |
640 KB |
in16.txt |
AC |
35 ms |
640 KB |
in17.txt |
AC |
17 ms |
640 KB |
in18.txt |
AC |
42 ms |
640 KB |
in19.txt |
AC |
21 ms |
640 KB |
in2.txt |
AC |
12 ms |
640 KB |
in20.txt |
AC |
37 ms |
640 KB |
in21.txt |
AC |
23 ms |
640 KB |
in22.txt |
AC |
21 ms |
640 KB |
in23.txt |
AC |
20 ms |
640 KB |
in24.txt |
AC |
23 ms |
640 KB |
in25.txt |
AC |
20 ms |
640 KB |
in26.txt |
AC |
21 ms |
640 KB |
in27.txt |
AC |
21 ms |
640 KB |
in28.txt |
AC |
23 ms |
640 KB |
in29.txt |
AC |
20 ms |
640 KB |
in3.txt |
AC |
13 ms |
640 KB |
in30.txt |
AC |
20 ms |
640 KB |
in31.txt |
AC |
12 ms |
640 KB |
in32.txt |
AC |
13 ms |
640 KB |
in33.txt |
AC |
22 ms |
640 KB |
in34.txt |
AC |
25 ms |
640 KB |
in35.txt |
AC |
22 ms |
640 KB |
in36.txt |
AC |
1 ms |
256 KB |
in37.txt |
AC |
1 ms |
256 KB |
in4.txt |
AC |
12 ms |
640 KB |
in5.txt |
AC |
13 ms |
640 KB |
in6.txt |
AC |
13 ms |
640 KB |
in7.txt |
AC |
12 ms |
640 KB |
in8.txt |
AC |
12 ms |
640 KB |
in9.txt |
AC |
13 ms |
640 KB |
sample1.txt |
AC |
1 ms |
256 KB |
sample2.txt |
AC |
1 ms |
256 KB |
sample3.txt |
AC |
1 ms |
256 KB |