結果

問題 No.432 占い(Easy)
ユーザー itezpace
提出日時 2017-02-15 06:25:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 593 ms
コンパイル使用メモリ 55,900 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-29 22:50:22
合計ジャッジ時間 1,617 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
int main(){
  int T;
  cin>>T;
  for(int i=0;i<T;++i){
    string s;
    cin>>s;
    while(1){
      if(s.size()==1) break;
      string s2;
      for(int j=0;j<s.size()-1;++j){
        int a=s[j];
        a-=48;
        int b=s[j+1];
        b-=48;
        int c=a+b;
        if(c>=10){
          string s_i=to_string(c);
          int c_a=s_i[0];
          c_a-=48;
          int c_b=s_i[1];
          c_b-=48;
          int c_c=c_a+c_b;
          c=c_c;
        }
        c+=48;
        char d=c;
        s2+=d;
      }
      s=s2;
    }
    cout<<s<<endl;
  }
}
0