結果

問題 No.432 占い(Easy)
ユーザー k
提出日時 2020-06-25 16:19:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 1,990 ms
コンパイル使用メモリ 196,644 KB
最終ジャッジ日時 2025-01-11 10:13:07
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);

int solve(const string &s) {
  int ret = 0;
  vector<int> a;
  for (char c: s) a.push_back(c - '0');

  while (a.size() > 1) {
    for (int i = 0; i + 1 < a.size(); i++) {
      a[i] += a[i+1];
      if (a[i] >= 10) {
        a[i] = a[i] / 10 + a[i] % 10;
      }
    }
    a.pop_back();
  }
  return a[0];
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int T;
  cin >> T;
  while (T--) {
    string s;
    cin >> s;
    cout << solve(s) << endl;
  }
  return 0;
}
0