poj 2575
2012-10-11 18:59
211 查看
题目连接:http://poj.org/problem?id=2575
题目解析:求给出序列的各个值之差是否能覆盖1~n-1,要是能,输出:"Jolly",否则输出:"Not jolly",其实不难,只要把各个值得绝对值求出来,看能否覆盖1~n-1。
代码:
题目解析:求给出序列的各个值之差是否能覆盖1~n-1,要是能,输出:"Jolly",否则输出:"Not jolly",其实不难,只要把各个值得绝对值求出来,看能否覆盖1~n-1。
代码:
#include<cstdio> #include<iostream> #include<algorithm> #include<cmath> #include<string> #include<cstring> using namespace std; int flag[3001], num[3001]; int Fac(int n) { memset(flag,0,sizeof(flag)); memset(num,0,sizeof(num)); int i,j,k,f,res=0; for(i=1;i<=n;i++) cin>>num[i]; for(k=2;k<=n;k++){ f=abs(num[k]-num[k-1]); if(f<3001) flag[f]=f; } for(j=1;j<n;j++) if(!flag[j]){ res=1;break; } if(res) cout<<"Not jolly"<<endl; else cout<<"Jolly"<<endl; return 0; } int main() { int n; while(cin>>n) Fac(n); return 0; }
相关文章推荐
- POJ 2575
- poj 2575 Jolly Jumpers
- POJ2575 Jolly Jumpers
- poj 2575 Jolly Jumpers
- POJ2575 Jolly Jumpers C语言
- poj 2575 Jolly Jumpers
- POJ 2575 Jolly Jumpers(简单题)
- poj 2575 Jolly Jumpers
- POJ 2575 && ZOJ 1879 Jolly Jumper(整数序列)
- poj2575-Jolly Jumpers
- zoj 1879 || poj 2575 Jolly Jumpers(水~)
- POJ 2575 Jolly Jumpers(水~)
- POJ 2575 Jolly Jumpers G++
- poj解题报告——poj 2575 Jolly Jumpers
- POJ 2575
- POJ-2575(用例能过,但一直WA)
- POJ 2575 Jolly Jumpers 解题报告
- POJ 2575 Jolly Jumpers(我的水题之路——数组绝对差值为1到n-1)
- zoj 2887 || poj 3439 Server Relocation
- poj 1556 The Doors(最短路+判断线段相交)