結果
| 問題 |
No.1237 EXP Multiple!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-26 17:08:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 515 bytes |
| コンパイル時間 | 1,728 ms |
| コンパイル使用メモリ | 194,532 KB |
| 最終ジャッジ日時 | 2025-01-14 22:27:52 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 15 WA * 4 |
コンパイルメッセージ
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) continue;
rep(j,fact){
if(ans>MOD) break;
ans*=a[i];
}
}
printf("%lld\n",MOD%ans);
return 0;
}