結果

問題 No.1237 EXP Multiple!
ユーザー kotatsugame
提出日時 2020-09-26 07:57:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 4,087 ms
コンパイル使用メモリ 63,860 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 17:23:26
合計ジャッジ時間 2,139 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
long ans=1e9+7,T=1;
int A[2<<17];
main()
{
	cin>>N;
	bool f=false,g=false;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		if(A[i]==0)
		{
			f=true;
			break;
		}
		else if(A[i]>=4)
		{
			g=true;
		}
		else
		{
			if(ans>=T)
			{
				if(A[i]==1)T*=1;
				else if(A[i]==2)T*=4;
				else T*=729;
			}
		}
	}
	if(f)cout<<-1<<endl;
	else if(g)cout<<ans<<endl;
	else cout<<ans%T<<endl;
}
0