結果

問題 No.434 占い
ユーザー conf
提出日時 2016-10-14 23:02:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 690 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 66,744 KB
実行使用メモリ 13,764 KB
最終ジャッジ日時 2024-11-22 09:16:35
合計ジャッジ時間 23,966 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <utility>
using namespace std;
int main(){
    int T;
    cin>>T;
    while(T--){
        string S;
        cin>>S;
        queue<int> Q1,Q2;
        while(!Q1.empty())Q1.pop();
        while(!Q2.empty())Q2.pop();
        for(auto c:S){
            Q1.push(c-'0');
        }
        while(Q1.size()>1){
            int i=Q1.front();
            Q1.pop();
            while(!Q1.empty()){
                Q2.push((i+Q1.front()>=10)?((i+Q1.front())/10+(i+Q1.front())%10):(i+Q1.front()));
                i=Q1.front();
                Q1.pop();
            }
            swap(Q1,Q2);
        }
        cout<<Q1.front()<<endl;
    }

    return 0;
}
0