結果

問題 No.432 占い(Easy)
ユーザー yoichi-e
提出日時 2016-10-14 22:49:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 60,836 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-22 08:13:15
合計ジャッジ時間 1,439 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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