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

直接枚举16ms...代码

Posted by ltf1320 at 2012-09-12 23:03:15 on Problem 1426
数据太水了...可以用long long 存下
#include <iostream>
#include <cstdio>

using namespace std;

const int maxn=100+10;
const int end=20;
int n;

long long now;
void plusOne()
{
    int tmp=10;
    while(true)
    {
        if(now%tmp>=tmp/10)
        {
            now-=tmp/10;
        }
        else break;
        tmp*=10;
    }
    now+=tmp/10;
}

int main()
{
 //   freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        if(!n) break;
        now=1;
        while(now%n)
            plusOne();
        printf("%lld\n",now);
    }
    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