Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

审题要注意了,关键词是take on all the values 1 through n-1,差的绝对值要取到1到n-1的所有值

Posted by 2004140022 at 2015-11-25 10:07:58 on Problem 2575
看了2眼以为差不大于n,果真我以为的只是我以为的。弱到爆~~~
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<algorithm>
#define N 3001
using namespace std;
int s[N];
int main()
{
    int n,a,b,tmp,i;
    while(scanf("%d",&n)!=EOF)
    {
        memset(s,0,sizeof(s));
        b=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&a);
            tmp=abs(a-b);
            s[tmp]=1;
            b=a;
        }
        for(i=1;i<n;i++)
            if(!s[i])break;
        if(n==i)
            puts("Jolly");
        else
            puts("Not jolly");
    }
return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator