結果

問題 No.432 占い(Easy)
ユーザー chacoder1
提出日時 2021-05-03 20:08:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 193,512 KB
最終ジャッジ日時 2025-01-21 06:23:15
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long

signed main(void) {
  int t;
  cin>>t;
  string s;
  rep(tn,t){
    cin>>s;
    int n=s.length();
    int a[n];
    int nx=n;
    rep(i,n) a[i]=s[i]-'0';
    
    while(nx>1){
      rep(j,nx-1){
        if(a[j]+a[j+1]<=9){
          a[j]=a[j]+a[j+1];
        }
        else{
          a[j]=a[j]+a[j+1]-9;
        }
      }
      nx--;
      //cout<<nx<<"#"<<a[0]<<endl;
    }
    cout<<a[0]<<endl;
  }
}

    
0