結果

問題 No.434 占い
ユーザー yoichi-e
提出日時 2016-10-14 23:55:25
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 578 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 61,472 KB
実行使用メモリ 13,768 KB
最終ジャッジ日時 2024-11-22 07:33:35
合計ジャッジ時間 34,767 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 TLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int K;
    cin>>K;
    for(int i=0;i<K;i++){
        string s;
        cin>>s;
        if(s.size()==1) {cout<<s<<endl;continue;}
        while(1){
            string c;
            for(int j=0;j<s.size()-1;j++) {
                int x = s[j] - '0' + s[j+1] - '0';
                if ( x > 9 ) c = c + to_string(1+x%10);
                else c = c + to_string(x);
            }
            if(c.size() == 1 ) {cout<<c<<endl;break;}
            s = c;
        }
    }
    return 0;
}
0