#include<stdio.h>
#include<algorithm>
using namespace std;
#define M 1000000007LL
int n;
long long int d[100009];
long long int a[100009];
long long int gcd(long long int p,long long int q)
{
while(p%q)q^=p^=q^=p%=q;
return q;
}
int main()
{
int i, j;
scanf("%d %d",&i,&n);
if(i>2)printf("1\n");
else
{
for(i=0;i<n;i++)
{
scanf("%lld",&a[i]);
}
sort(a,a+n);
n=unique(a,a+n)-a;
long long int res = 0;
for(i=0;i<n;i++)
{
res += a[i];
long long int k = a[i], l;
for(l=1;l*l<=a[i];l++)
{
long long int g;
g = gcd(a[i],l);
if(g > 1)
{
k -= d[g];
}
}
d[a[i]] = k;
res += k;
}
printf("%lld\n",res);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |