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

数据有点儿弱

Posted by SCSE10_Candybox at 2011-02-02 00:53:13 on Problem 2769
 SCSE10_Candybox 2769 Accepted 224K 297MS C++ 606B 
贡献了两个RE,NN=500和5000的时候RE了..然后50000就过了...踩一脚
#include <iostream>
using namespace std;
const int NN=50000;

int t,a[NN],n;
bool work(int x)
{
     bool f[NN];
     memset(f,0,sizeof(f));
     for (int i=1;i<=n;++i)
         if (f[a[i]%x]) return false;
         else f[a[i]%x]=1;
     return true;
}
int main()
{
    scanf("%d",&t);
    for (int xx=1;xx<=t;++xx)
    {
        scanf("%d",&n);
        for (int i=1;i<=n;++i) scanf("%d",&a[i]);
        for (int v=n;;++v)
        {
            if (work(v))
            {
               printf("%d\n",v);
               break;
            }
        }
    }
    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