2016年11月10日 星期四

TIOJ 1299 - 第五題 大強者機器人傑洛!!算算看自己的等級吧?

http://tioj.infor.org/problems/1299



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    while(cin>>s){
        int a=0;
        for(int i=0;i<(int)s.length();i++){
            if(s[i]>='a')s[i]-=32;
            a+=s[i]-'A'+1;
        }
        a%=17;
        if(a<3)cout<<"D\n";
        else if(a<6)cout<<"C\n";
        else if(a<10)cout<<"B\n";
        else if(a<13)cout<<"A\n";
        else cout<<"SA\n";
    }
}

沒有留言:

張貼留言