結果
問題 |
No.432 占い(Easy)
|
ユーザー |
![]() |
提出日時 | 2020-12-27 20:28:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 1,118 bytes |
コンパイル時間 | 911 ms |
コンパイル使用メモリ | 97,100 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-01 19:46:23 |
合計ジャッジ時間 | 1,886 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include<iostream> #include<stdio.h> #include<stdlib.h> #include<string.h> #include<algorithm> #include<vector> #include<math.h> #include<iomanip> #include<stack> #include<queue> #include<set> #include<map> #include<numeric> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; //const ll mod = 1000000007; const ll mod = 998244353; const ld pi = 3.14159265358979; vector<int> ans; int calc(int x){ int sum = 0; while(x > 0){ sum += x % 10; x /= 10; } return sum; } int solver(){ string s; cin >> s; while(s.size() > 1){ string t; for(int i = 0; i < s.size() - 1; i++){ int now = int(s[i] - '0') + int(s[i + 1] - '0'); if(now < 10){ t += to_string(now); }else{ t += to_string(calc(now)); } } s = t; } return int(s[0] - '0'); } int main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(15); int t; cin >> t; for(int i = 0; i < t; i++){ ans.push_back(solver()); } for(int i = 0; i < t; i++){ cout << ans[i] << '\n'; } return 0; }