結果

問題 No.933 おまわりさんこいつです
ユーザー ate
提出日時 2019-11-29 21:58:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 1,267 bytes
コンパイル時間 2,122 ms
コンパイル使用メモリ 195,860 KB
最終ジャッジ日時 2025-01-08 05:55:40
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

signed main(){

  ll n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  auto f = [](ll p){
    ll x=0;
    while(p){
      x+=p%10;
      p/=10;
    }
    return x;
  };

  for(auto& ai:a){
    while(ai>=10)ai = f(ai);
  }

  ll ans = 1;
  for(auto ai:a){
    ans*=ai;
    ans = f(ans);
  }
  
  while(ans>=10)ans=f(ans);

  cout<<(ans)<<endl;

}
0