結果
| 問題 | 
                            No.1237 EXP Multiple!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-09-26 17:11:39 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 27 ms / 2,000 ms | 
| コード長 | 534 bytes | 
| コンパイル時間 | 1,928 ms | 
| コンパイル使用メモリ | 193,712 KB | 
| 最終ジャッジ日時 | 2025-01-14 22:28:55 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 19 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         int n; scanf("%d",&n);
      |                ~~~~~^~~~~~~~~
main.cpp:13:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         rep(i,n) scanf("%d",&a[i]);
      |                  ~~~~~^~~~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
const int MOD=1e9+7;
int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);
	if(count(a.begin(),a.end(),0)>0){
		puts("-1");
		return 0;
	}
	lint ans=1;
	rep(i,n) if(a[i]>1) {
		lint fact=1;
		rep(j,a[i]){
			fact*=j+1;
			if(fact>100) break;
		}
		if(fact>100){
			ans=MOD+1;
			break;
		}
		rep(j,fact){
			if(ans>MOD) break;
			ans*=a[i];
		}
	}
	printf("%lld\n",MOD%ans);
	return 0;
}