結果

問題 No.1237 EXP Multiple!
ユーザー okok
提出日時 2020-09-25 22:18:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 7,408 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 83,152 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-06-28 06:41:40
合計ジャッジ時間 4,100 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 57 ms
6,812 KB
testcase_02 AC 78 ms
6,940 KB
testcase_03 AC 80 ms
6,940 KB
testcase_04 AC 85 ms
6,944 KB
testcase_05 RE -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 AC 31 ms
6,940 KB
testcase_13 AC 31 ms
6,940 KB
testcase_14 AC 33 ms
6,940 KB
testcase_15 AC 32 ms
6,944 KB
testcase_16 AC 32 ms
6,944 KB
testcase_17 AC 32 ms
6,940 KB
testcase_18 AC 32 ms
6,944 KB
testcase_19 AC 32 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

const int MAX = 1'000'000;
int ar[MAX] = {1,345834424,684533106,1536262,657144572,671775730,182247942,720327320,717812688,416392206,491349362,427568318,184220276,690262168,486364052,970060584,871826684,379630614,977449242,60230474,416101758,595857638,301269484,909120488,112813080,559031636,787816624,612620670,547890024,922349344,566659512,184058708,588883314,375490578,836176520,468160112,492523342,151739228,132617002,373457030,222513694,420034832,874734486,473809442,349500416,725298292,278012486,40687264,33571734,835784536,322574016,553013506,163273008,413327920,444001700,30666048,548583784,400306194,648241114,87575950,476749590,429755820,104670530,454573360,583252894,70875596,535146228,756929138,407228486,905205286,498897322,660245312,593840050,354507516,24051082,914167874,912543946,650300612,768560000,402930356,901069388,470370008,850646300,90625124,580564092,333608290,768518696,135144854,462591870,360463724,549155904,803851838,879477132,995502368,594801568,829636814,917121280,290696854,656769392,827600470,584455382,341558996,768238626,867377414,694412398,824761392,844566992,930951936,540396140,360579872,974995962,290504762,112613080,278454208,353222288,885948856,422434458,828990912,686686928,136443800,662972046,423029272,149479828,159238352,153839748,337496712,133457486,679055944,343400428,718154590,567007624,659860748,710304888,829105616,362518470,923934986,749693802,897060982,767832542,895330202,699117714,427986210,917414554,207863262,891743372,410984830,203193256,327901940,354031526,60630024,893316440,582402322,297467838,714192510,896723498,397254790,90530196,903095346,47618944,765414392,489493348,189854470,196677586,778700306,713544656,870664166,729097828,881763638,325567138,770725180,728300782,229202046,277917622,604750902,69871318,912220684,603763832,109265666,587164682,738824718,129182456,115960722,219465188,735374342,792644464,690361798,326210338,238304658,985284664,817195778,600865306,947648396,168473552,57846510,353880760,381184274,478361894,806752752,210528500,871162164,118793266,522746202,306824104,141559874,169589662,550494986,50058434,331731692,819125684,446155704,824896822,533430884,923106996,509534788,518823026,348523550,128282,326407828,306318674,889579824,706822080,279931332,423633734,340063158,708939162,676646328,774212532,220963704,799608870,913161494,800177674,794247112,83763588,164685794,814396142,560618242,28037102,979939020,179571280,739894526,649033318,585042606,521343166,572435568,611817340,187704748,916968532,510103596,587609636,887526058,1000000004,898996186,473538916,587344950,14292898,500769240,224716638,288864536,323089228,922623990,259230080,921908562,816643746,629828510,765025616,551481696,262052912,530465434,43740536,370211764,335751860,95843558,404468382,698594452,982392048,203824814,977646050,438714260,545620896,429344770,24479328,702112496,789775934,10494476,213044110,226414714,289348038,277389652,933710446,289140558,631349862,351300776,726311398,715683580,861821296,106656774,980029044,340044166,594225096,186402068,173234144,807180820,999656720,382463200,257587696,321876830,499847188,790254098,541200820,660450716,634475744,592578840,815597182,959908078,354573774,497225994,996261408,632415556,182289344,346945750,984694894,670201342,380741270,966667014,233306878,73314308,498636556,853527384,347749482,658995414,374263948,518674676,528927994,100185886,221145108,479578740,315137860,335081636,74115728,831870250,350534396,763443404,944909954,888052364,868719910,603524396,302588504,369844414,698501634,275852236,222962910,179897494,944189608,648998490,2478106,625561186,496503842,381445304,570518998,386075952,764426440,702319386,958840348,997706520,661341470,973165738,471417146,679524686,256226778,512825308,982625410,505059696,626148860,382777998,624171786,742866700,598349816,563987356,323473010,141735330,942170022,72589630,687843202,397078824,485502472,571308298,490107894,637154666,270247200,968042160,363985242,218274886,341598498,413297584,172742894,295940362,492961004,541579010,39168186,354230502,861483098,129819092,620600732,429907676,495674148,247090550,321654880,741759578,375804108,183547794,92389162,317155684,284331696,695263778,385484872,437983154,374498010,336646390,222968166,406075774,539439492,629893062,122943788,179228032,682165324,772028726,374181580,415731352,219872682,257972570,413990606,206875484,293093100,61958414,388463126,654774480,364022686,473264646,354570364,517623006,928151592,82317276,402768104,753061192,741906674,527306154,958363454,279937876,254460142,122109362,984355652,399215258,563890852,594140734,270262984,194798910,321692960,515709202,412719790,909225464,506773120,558743954,767506942,732536334,588223838,696327670,403956142,78918354,540330630,86922202,25458476,856995524,853144374,898533286,839346502,168726488,839706280,653814036,213330282,420005666,36652844,285281664,741411084,776995284,114436322,137901326,971988088,344526418,582385926,632469058,82592062,522503140,460910164,911590080,57742184,771396566,306932230,567913086,279926280,40360120,750000004,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};

int  solve(int n){
	static constexpr int MOD = 1e9+6;
	int factorial = 1;

	if(n >= MOD){
		cout<<0<<endl;
		return 0;
	}
	
	factorial = ar[n/MAX];
	
	for(int i = n/MAX*MAX + 1; i <= n; i++){
		factorial *= i;
		factorial %= MOD;
		if(factorial == 0) break;
	}
	
	// cout<<factorial<<endl;
	
	return factorial;
}

long long power(long long x, long long n){
	long long ans = 1;
	int N = n;
	
	if(x >= 4) return -1;
	
	n = 1;
	
	for(int i = 1; i <= N; i++){
		n *= i;
	}
	// cout<<"n = "<<n<<endl;
		
	for(;n;n >>= 1, x *= x) {
		if(n&1)ans*=x;
		if(ans > MOD) return -1;
	}
	
	return ans;
}


signed main(){
	
	int N;
	int zero = 0;
	int ans = 1;
	vector<int> A;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		if(A[i] == 0)zero++;
	}
	
	if(zero == 1) {
		cout<<-1<<endl;
		return 0;
	}
	
	for(int i = 0; i < N; i++){
		int t = power(A[i], A[i]);
		if(t == -1) {
			cout<<MOD<<endl;
			return 0;
		}
		
		ans *= t;
		
		if(ans > MOD) {
			cout<<"ans"<<" "<<ans<<endl;
			cout<<MOD<<endl;
			return 0;
		}
	}
	
	cout<<MOD%ans<<endl;
	
	return 0;
}
0