結果
| 問題 |
No.432 占い(Easy)
|
| コンテスト | |
| ユーザー |
kyuridenamida
|
| 提出日時 | 2016-10-28 18:46:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 496 bytes |
| コンパイル時間 | 513 ms |
| コンパイル使用メモリ | 63,776 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-24 05:14:51 |
| 合計ジャッジ時間 | 1,322 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <sstream>
using namespace std;
char g(string s){
int ans = 0;
for(auto c : s )
ans += c - '0';
return ans % 10 + ans / 10 % 10 + '0';
}
int f(string S){
if( S.size() == 1 )
return S[0] - '0';
string r;
for(int i = 0 ; i + 1 < S.size() ; i++)
r += g(S.substr(i,2));
return f(r);
}
int main(){
int N;
cin >> N;
while(N--){
string S;
cin >> S;
cout << f(S) << endl;
}
}
kyuridenamida