Submission #1445417
Source Code Expand
#include <cstdio>
#include <algorithm>
using namespace std;
int gcd(int a, int b)
{
if(a == 0 || b == 0)
return (a + b);
else
return gcd(min(a, b), max(a, b)%min(a, b));
}
int main()
{
int no_of_numbers, desired_number;
scanf("%d %d", &no_of_numbers, &desired_number);
int array_gcd, largest_number = 0;
for(int i = 1; i <= no_of_numbers; i++)
{
int number_i;
scanf("%d", &number_i);
array_gcd = (i == 1 ? number_i : gcd(array_gcd, number_i));
largest_number = max(number_i, largest_number);
}
printf(desired_number%array_gcd == 0 && desired_number <= largest_number ? "POSSIBLE\n" : "IMPOSSIBLE\n");
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Getting Difference |
User |
Saikat |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
738 Byte |
Status |
AC |
Exec Time |
12 ms |
Memory |
128 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:17:52: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &no_of_numbers, &desired_number);
^
./Main.cpp:23:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &number_i);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
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 |
0 ms |
128 KB |
subtask_1_01.txt |
AC |
0 ms |
128 KB |
subtask_1_02.txt |
AC |
0 ms |
128 KB |
subtask_1_03.txt |
AC |
12 ms |
128 KB |
subtask_1_04.txt |
AC |
12 ms |
128 KB |
subtask_1_05.txt |
AC |
7 ms |
128 KB |
subtask_1_06.txt |
AC |
2 ms |
128 KB |
subtask_1_07.txt |
AC |
7 ms |
128 KB |
subtask_1_08.txt |
AC |
11 ms |
128 KB |
subtask_1_09.txt |
AC |
5 ms |
128 KB |
subtask_1_10.txt |
AC |
9 ms |
128 KB |
subtask_1_11.txt |
AC |
10 ms |
128 KB |