# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
9132 | pichulia | Actual visible points (kriii2_AC) | C++98 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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("%lld\n",(&j)%M);
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);
}
}