Submission #1449642


Source Code Expand

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int n,k,g[101000];
int main() {
	scanf("%d%d",&n,&k);
	rep(i,0,n) scanf("%d",g+i);
	sort(g,g+n);
	if (g[0]==g[n-1]) {
		puts(g[0]==k?"POSSIBLE":"IMPOSSIBLE");
		return 0;
	}
	int d=g[n-1]-g[0];
	rep(i,0,n-1) if (g[n-1]!=g[i]) d=__gcd(d,g[n-1]-g[i]);
	if (k<=g[n-1]&&(g[n-1]-k)%d==0) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}

Submission Info

Submission Time
Task A - Getting Difference
User apiad
Language C++14 (GCC 5.4.1)
Score 300
Code Size 999 Byte
Status AC
Exec Time 19 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:28:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
                     ^
./Main.cpp:29:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  rep(i,0,n) scanf("%d",g+i);
                            ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt
Case Name Status Exec Time Memory
sample_01.txt AC 0 ms 128 KB
sample_02.txt AC 0 ms 128 KB
sample_03.txt AC 0 ms 128 KB
sample_04.txt AC 1 ms 128 KB
subtask_1_01.txt AC 1 ms 128 KB
subtask_1_02.txt AC 0 ms 128 KB
subtask_1_03.txt AC 19 ms 512 KB
subtask_1_04.txt AC 13 ms 512 KB
subtask_1_05.txt AC 7 ms 384 KB
subtask_1_06.txt AC 3 ms 256 KB
subtask_1_07.txt AC 11 ms 384 KB
subtask_1_08.txt AC 17 ms 512 KB
subtask_1_09.txt AC 8 ms 384 KB
subtask_1_10.txt AC 13 ms 384 KB
subtask_1_11.txt AC 15 ms 512 KB