[ZJd123][UVA11063 ] B2-Sequence
題目:
http://zerojudge.tw/ShowProblem?problemid=d123
--------------------------------------------------------------------------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
int main()
{
int b[100],n,T = 1;
while(scanf("%d",&n)!=EOF)
{
for(int i=0;i<n;i++)
scanf("%d",&b[i]);
int a[20001]={0}, z = 1;
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
if(a[b[i]+b[j]] !=0)
{
z = 0;
break;
}
if(a[b[i]+b[j]] == 0)
a[b[i]+b[j]]++;
}
if(z == 0)
break;
}
printf("Case #%d: It is %s.\n",T++,(z)?"a B2-Sequence":"not a B2-Sequence");
}
return 0;
}
http://zerojudge.tw/ShowProblem?problemid=d123
--------------------------------------------------------------------------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
int main()
{
int b[100],n,T = 1;
while(scanf("%d",&n)!=EOF)
{
for(int i=0;i<n;i++)
scanf("%d",&b[i]);
int a[20001]={0}, z = 1;
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
if(a[b[i]+b[j]] !=0)
{
z = 0;
break;
}
if(a[b[i]+b[j]] == 0)
a[b[i]+b[j]]++;
}
if(z == 0)
break;
}
printf("Case #%d: It is %s.\n",T++,(z)?"a B2-Sequence":"not a B2-Sequence");
}
return 0;
}
留言
張貼留言