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 guangmingge at 2013-09-19 10:13:27 on Problem 1152
#include<iostream>
using namespace std;

int main(){
    string str;
    int num;
    int n;
    while(cin>>str){
        if(str=="0"){
            cout<<2<<endl;
            continue;
        }
        num=0;
        int ma(0);
        for(int i=0;i<str.length();i++){
            int pos = str[i];
            if(pos<58){
                    pos = pos - 48;
            }else if(pos<91){
                    pos = pos - 55;
            }else{
                    pos = pos - 61;
            }
            if(pos>ma)
                ma = pos;
            num = num + pos;
        }
        n = ma + 1;
        while(true){
            if(num%(n-1)==0)
                    break;
            n++;
        }
        if(n<63)
            cout<<n<<endl;
        else
            cout<<"such number is impossible!"<<endl;
    }
}

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