結果

問題 No.933 おまわりさんこいつです
ユーザー toto6114
提出日時 2019-11-30 00:33:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 709 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 92,240 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 00:23:18
合計ジャッジ時間 1,700 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,p[100005]={},ans=1,cnt=0,x,A,y,B;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> p[i];
    x=p[i];
    cnt=0;
    while(x>0) {
      cnt+=x%10;
      x/=10;
    }
    ans*=cnt;
    B=ans;
    while(B>9) {
      B=0;
      while(ans>0) {
        B+=ans%10;
        ans/=10;
      }
      ans=B;
    }
  }
  A=ans;
  while(A>9) {
    A=0;
    while(ans>0) {
      A+=ans%10;
      ans/=10;
    }
    ans=A;
  }
  cout << A << endl;
}
0