結果

問題 No.1237 EXP Multiple!
ユーザー Rayhan AhmadRayhan Ahmad
提出日時 2020-09-26 02:18:56
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 969 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 135,024 KB
実行使用メモリ 4,748 KB
最終ジャッジ日時 2023-09-10 19:35:04
合計ジャッジ時間 3,637 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 70 ms
4,376 KB
testcase_02 AC 95 ms
4,696 KB
testcase_03 AC 98 ms
4,700 KB
testcase_04 AC 92 ms
4,700 KB
testcase_05 AC 36 ms
4,708 KB
testcase_06 AC 36 ms
4,700 KB
testcase_07 AC 38 ms
4,696 KB
testcase_08 AC 36 ms
4,724 KB
testcase_09 AC 36 ms
4,700 KB
testcase_10 AC 36 ms
4,700 KB
testcase_11 AC 35 ms
4,692 KB
testcase_12 AC 35 ms
4,700 KB
testcase_13 AC 35 ms
4,748 KB
testcase_14 AC 37 ms
4,732 KB
testcase_15 AC 36 ms
4,648 KB
testcase_16 AC 36 ms
4,692 KB
testcase_17 AC 36 ms
4,696 KB
testcase_18 AC 35 ms
4,744 KB
testcase_19 AC 35 ms
4,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
            }
            answer = mod % ans;
        }
    }
    cout << answer << endl;
}
0