#include <bits/stdc++.h>
using namespace std;
long long bitmask[50005];
int mmare[50005];
int dl[]={-1,-1,0,1,1,1,0,-1};
int dc[]={0,1,1,1,0,-1,-1,-1};
bool prime(int x,int y)
{
if (x==1||y==1)
{
return true;
}
if (x==0||y==0)
{
return false;
}
if (bitmask[x]&bitmask[y])
{
return false;
}
if (mmare[x]==mmare[y]&&mmare[y]>1)
{
return false;
}
return true;
}
long long sum=0;
void fractal(int x,int y,int lung,int dir,int jum)
{
if (lung==0)
{
return;
}
int i;
for (i=1;i<=lung;i++)
{
x=x+dl[dir];
y=y+dc[dir];
sum=sum+prime(x,y);
}
if (jum==1)
{
lung=lung/2;
}
fractal(x,y,lung,(dir+1)&7,1-jum);
fractal(x,y,lung,(dir-1)&7,1-jum);
}
bool c[50005];
int n,m,frac,i,j,nr,x,y;
int main()
{
cin>>n>>m>>frac;
for (i=2;i<=50000;i++)
{
if (mmare[i]==0)
{
for (j=i;j<=50000;j+=i)
{
mmare[j]=i;
}
}
}
for (i=2;i*i<=50000;i++)
{
if (c[i]==0)
{
for (j=i;j<=50000;j+=i)
{
c[j]=1;
bitmask[j]+=(1<<nr);
}
nr++;
}
}
for (i=1;i<=frac;i++)
{
cin>>x>>y>>nr;x--;y--;
sum=sum+prime(x,y);
fractal(x,y,nr,0,1);
}
cout<<sum;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
932 KB |
Output isn't correct |
2 |
Incorrect |
21 ms |
932 KB |
Output isn't correct |
3 |
Incorrect |
396 ms |
844 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
664 ms |
912 KB |
Output isn't correct |
2 |
Incorrect |
637 ms |
908 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1044 ms |
932 KB |
Output isn't correct |
2 |
Incorrect |
1111 ms |
844 KB |
Output isn't correct |
3 |
Incorrect |
1122 ms |
912 KB |
Output isn't correct |
4 |
Incorrect |
1194 ms |
912 KB |
Output isn't correct |
5 |
Incorrect |
1233 ms |
908 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2165 ms |
912 KB |
Output isn't correct |
2 |
Incorrect |
2282 ms |
912 KB |
Output isn't correct |
3 |
Incorrect |
2428 ms |
916 KB |
Output isn't correct |
4 |
Incorrect |
2564 ms |
916 KB |
Output isn't correct |
5 |
Incorrect |
2741 ms |
916 KB |
Output isn't correct |
6 |
Incorrect |
2813 ms |
912 KB |
Output isn't correct |
7 |
Incorrect |
2931 ms |
920 KB |
Output isn't correct |
8 |
Incorrect |
2980 ms |
964 KB |
Output isn't correct |
9 |
Incorrect |
2933 ms |
964 KB |
Output isn't correct |
10 |
Incorrect |
2983 ms |
920 KB |
Output isn't correct |