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

附代码,知道tle 的痛苦,0ms秒过

Posted by peijian at 2012-04-09 17:24:14 on Problem 1781
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int get(int num){
    if(num==1)return 0;
    else if(num&1)return (get(num/2)+1)*2%(num+1);
    else return (get(num/2)*2)%(num);
}
int main()
{
    //freopen("in.txt","r",stdin);
    char c[5];
    int a,b,d;
    while(scanf("%s",c)){
        a=c[0]-'0',b=c[1]-'0',d=c[3]-'0';
        if(a==0&&b==0&&d==0)break;
        int num=(a*10+b)*(int)pow(10,d*1.0);
        int ans=get(num)+1;
        cout<<ans<<endl;
    }
    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