結果

問題 No.432 占い(Easy)
ユーザー Yut176Yut176
提出日時 2016-10-14 23:09:20
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 67,624 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-22 09:56:21
合計ジャッジ時間 1,484 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){

	int t;
	cin >> t;
	vector<string> s(t);
	for(int i=0; i<t; i++) cin >> s[i];

	for(int i=0; i<t; i++){

		string a = s[i];
		if( a.size() == 1 ){
			cout << a << endl;
		}else{
			int p = 1;
			for(int j=0; j<s[i].size(); j++){
				for(int k=0; k<s[i].size()-p; k++){
					int tmp = a[k]-'0' + a[k+1]-'0';
					if( tmp >= 10 ){
						a[k] = to_string( tmp/10 + tmp%10 )[0];
					}else{
						a[k] = to_string(tmp)[0];
					}
				}
				p++;
			}
			cout << a[0] << endl;
		}

	}

	return 0;
}
0