結果
問題 |
No.1237 EXP Multiple!
|
ユーザー |
![]() |
提出日時 | 2020-09-25 22:29:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 710 bytes |
コンパイル時間 | 2,742 ms |
コンパイル使用メモリ | 191,412 KB |
最終ジャッジ日時 | 2025-01-14 21:09:36 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 17 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d", &a[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> #define REP(i,b,e) for(int i=b;i<e;i++) const int MOD = 1e9+7; int main(){ int n; scanf("%d", &n); int a[n], zero = 0, huge = 0; REP(i, 0, n){ scanf("%d", &a[i]); if(a[i]==0) zero++; if(a[i]>3) huge++; } if(zero) puts("-1"); else if(huge) printf("%d\n", MOD); else{ long long ans = 1; REP(i, 0, n){ REP(j, 1, a[i]+1){ REP(k, 0, j){ ans *= a[i]; if(ans>MOD){ printf("%d\n", MOD); return 0; } } } } printf("%lld\n", MOD%ans); } }