結果

問題 No.1237 EXP Multiple!
ユーザー milanis48663220milanis48663220
提出日時 2020-09-25 21:48:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,283 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 81,292 KB
実行使用メモリ 5,088 KB
最終ジャッジ日時 2023-09-10 17:24:22
合計ジャッジ時間 2,066 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 18 ms
4,604 KB
testcase_02 AC 25 ms
5,088 KB
testcase_03 AC 25 ms
4,980 KB
testcase_04 AC 28 ms
4,936 KB
testcase_05 AC 13 ms
5,000 KB
testcase_06 AC 14 ms
4,992 KB
testcase_07 AC 13 ms
4,936 KB
testcase_08 AC 14 ms
5,004 KB
testcase_09 AC 14 ms
4,924 KB
testcase_10 AC 14 ms
5,000 KB
testcase_11 AC 14 ms
4,920 KB
testcase_12 AC 14 ms
4,940 KB
testcase_13 AC 14 ms
5,000 KB
testcase_14 AC 14 ms
4,952 KB
testcase_15 AC 13 ms
5,052 KB
testcase_16 AC 14 ms
4,932 KB
testcase_17 AC 14 ms
4,928 KB
testcase_18 AC 14 ms
4,936 KB
testcase_19 AC 13 ms
5,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define N_MAX 200002

using namespace std;
typedef long long ll;


ll fac[N_MAX];

void init(ll MOD){
    fac[0]=1;fac[1]=1;
    for(int i=2;i<N_MAX;i++){
        fac[i]=fac[i-1]*(ll)i;
        fac[i] %= MOD;
    }
}

template <typename T>
T pow(T a, ll n, ll MOD) {
	T ans = 1;
	T tmp = a;
	for (int i = 0; i <= 60; i++) {
		ll m = (ll)1 << i;
		if (m & n) {
		ans *= tmp;
		ans %= MOD;
		}
		tmp *= tmp;
		tmp %= MOD;
	}
	return ans;
}

const ll p = 1000000007;

int N;
ll A[200000];

ll c[4] = {1, 1, 4, 729};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    bool too_big = false;
    bool contain_zero = false;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] == 0) contain_zero = true;
        if(A[i] >= 4) too_big = true;
    }
    if(contain_zero){
        cout << -1 << endl;
        return 0;
    }
    if(too_big){
        cout << p << endl;
        return 0;
    }
    ll ans = 1;
    for(int i = 0; i < N; i++){
        ans *= c[A[i]];
        if(ans > p){
            cout << p << endl;
            return 0;
        }
    }
    cout << p%ans << endl;
}
0