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

不打表204ms过,刚开始没保存数据超时了好多次!!!!!!!!

Posted by yangyangyang91 at 2011-06-22 22:21:14 on Problem 1012
#include<stdio.h>
int k;
int a[14];

int is_ok(int n)
{
    int rem=2*k;
    int kill=(n%rem?n%rem:rem);
    while(kill>k)
    {
        rem--;
        if(rem==k)return 1;
        kill=(kill+n-1)%rem;
        kill=kill?kill:rem;
    }
    return 0;
}

void main()
{
    int i,j;
    for(i=0;i<14;a[i++]=0);
    while(scanf("%d",&k)&&k)
    {
        if(a[k])goto inx;
        for(j=k;;j+=2*k)
        {
            for(i=j+1;i<=j+k;i++)
            {
                if(is_ok(i)){a[k]=i;goto inx;}
            }
        }
inx:
        printf("%d\n",a[k]);
    }
}

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