結果
| 問題 | No.933 おまわりさんこいつです | 
| コンテスト | |
| ユーザー |  occhan | 
| 提出日時 | 2019-11-29 23:07:40 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 76 ms / 2,000 ms | 
| コード長 | 847 bytes | 
| コンパイル時間 | 1,720 ms | 
| コンパイル使用メモリ | 176,704 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-20 23:49:37 | 
| 合計ジャッジ時間 | 2,879 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 25 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  map<P,ll> m;
  rep(i,10){
    reps(j,i,10){
      ll c=i*j,d=0LL;
      while(c>=10){
        ll d=0LL,b=c;
        while(b){
          d+=b%10;b/=10;
        }
        c=d;
      }
      m[P(i,j)]=c;m[P(j,i)]=c;
    }
  }
  ll n,a,r=1LL;cin>>n;
  rep(i,n){
    cin>>a;
    while(a>=10){
      ll b=a,d=0LL;
      while(b){
        d+=b%10;b/=10;
      }
      a=d;
    }
    r=m[P(r,a)];
  }
  cout<<r <<endl;
}
            
            
            
        