結果

問題 No.933 おまわりさんこいつです
ユーザー masa_ahe
提出日時 2019-11-29 22:24:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 753 ms
コンパイル使用メモリ 66,836 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-20 23:34:58
合計ジャッジ時間 2,082 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

typedef long long ll;

ll sumofdigits(ll x){
	ll ans=0;
	while(x){
		ans+=(x%10);
		x/=10;
	}
	return ans;
}

int main(){
	int n;
	cin>>n;
	vector<ll>p(n);
	for(int i=0;i<n;i++){
		cin>>p[i];
		while(p[i]>10){
			p[i]=sumofdigits(p[i]);
		}
	}
	ll tmp=1;
	for(int i=0;i<n;i++){
		tmp*=p[i];
		if(tmp>1e9){
			tmp=sumofdigits(tmp);
		}
	}
	while(tmp>=10){
		tmp=sumofdigits(tmp);
	}
	cout<<tmp<<endl;
	return 0;
}
0