結果

問題 No.432 占い(Easy)
ユーザー ouoz1Vouoz1V
提出日時 2016-10-15 00:05:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 1,284 ms
コンパイル使用メモリ 147,952 KB
実行使用メモリ 8,204 KB
最終ジャッジ日時 2023-08-14 11:35:37
合計ジャッジ時間 2,521 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 9 ms
8,088 KB
testcase_13 AC 9 ms
8,192 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 7 ms
8,204 KB
testcase_18 AC 5 ms
4,580 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 3 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<bits/stdc++.h>
using namespace std;

int henkan(int n){
    if(n>=10)return n%10+n/10;
    else return n;
}

int sub(vector<int> s){

    vector<int> ret;

    if(s.size()==1)return s[0];
    for(int i=0; i<s.size()-1; i++){
        ret.push_back(henkan(s[i]+s[i+1]));
    }

    return sub(ret);
}

int solve(string str){
    vector<int> s;
    for(int i=0; i<str.length(); i++){
        s.push_back(str[i]-'0');
    }
    return sub(s);
}

int main(){

    int T,S;
    string str;

    cin>>T;
    for(int i=0; i<T; i++){
        cin>>str;
        cout<<solve(str)<<endl;
    }

    return 0;
}
0