2 条题解
-
0
#include <bits/stdc++.h> using namespace std; const int N=2*255*255; int c[N];bool v[N]; int main() { int n,m;scanf("%d%d",&n,&m); memset(v,0,sizeof(v)); for(int a=0;a<=m;a++)for(int b=0;b<=m;b++)v[a*a+b*b]=True; int tot=0;for(int i=0;i<=2*m*m;i++)if(v[i])c[++tot]=i; bool flg=False; for(int b=1;b<=2*m*m;b++) { for(int i=1;i<tot;i++) { int a=c[i];if(a+b*(n-1)>c[tot])break; bool bk=True;for(int j=0;j<n;j++)if(!v[a+b*j]){bk=False;break;} if(bk){printf("%d %d\n",a,b);flg=True;} } } if(!flg)puts("NONE"); return 0; } -
0
#include <bits/stdc++.h> using namespace std; const int N=2*255*255; int c[N];bool v[N]; int main() { int n,m;scanf("%d%d",&n,&m); memset(v,0,sizeof(v)); for(int a=0;a<=m;a++)for(int b=0;b<=m;b++)v[a*a+b*b]=True; int tot=0;for(int i=0;i<=2*m*m;i++)if(v[i])c[++tot]=i; bool flg=False; for(int b=1;b<=2*m*m;b++) { for(int i=1;i<tot;i++) { int a=c[i];if(a+b*(n-1)>c[tot])break; bool bk=True;for(int j=0;j<n;j++)if(!v[a+b*j]){bk=False;break;} if(bk){printf("%d %d\n",a,b);flg=True;} } } if(!flg)puts("NONE"); return 0; }
- 1
信息
- ID
- 994
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- 递交数
- 75
- 已通过
- 28
- 上传者