結果
| 問題 | 
                            No.1237 EXP Multiple!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-09-26 02:03:37 | 
| 言語 | C++17(clang)  (17.0.6 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,080 bytes | 
| コンパイル時間 | 3,942 ms | 
| コンパイル使用メモリ | 164,184 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-28 10:22:10 | 
| 合計ジャッジ時間 | 5,844 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 12 WA * 7 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
const int mod = 1e9+7;
ll bigMod(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans = (ans*a);
        a = (a*a);
        b >>=1;
    }
    return ans;
}
int main()
{
    int n;
    cin >> n;
    vector<ll>arr(n);
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    sort(arr.begin(),arr.end());
    ll answer = 1;
    ll mn = *min_element(arr.begin(),arr.end());
    ll mx = *max_element(arr.begin(),arr.end());
    if(mn == 0) answer = -1;
     else if(mx >=4 )answer = mod;
    else
    {
        ll ans = 1;
        for(ll x : arr)
        {
            if(x==1)ans = ans;
            if(x==2)ans = (ans * bigMod(x,2));
            if(x==3)ans = (ans * bigMod(x,6));
            if(ans>mod)
            {
                answer = mod;
                break;
            }
            if(mod % ans == 0)
            {
                answer = -1;
                break;
            }
            answer = mod % ans;
        }
    }
    cout << answer << endl;
}