結果
問題 | No.1084 積の積 |
ユーザー |
|
提出日時 | 2020-06-19 21:47:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 513 bytes |
コンパイル時間 | 631 ms |
コンパイル使用メモリ | 67,776 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 14:14:40 |
合計ジャッジ時間 | 2,794 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 27 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#include<iostream>using namespace std;const long mod=1e9+7;long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}int N;long A[1<<17];main(){cin>>N;for(int i=0;i<N;i++){cin>>A[i];if(A[i]==0){cout<<0<<endl;return 0;}}int r=0;long now=1,ans=1,tmp=1;for(int l=0;l<N;l++){while(r<N&&tmp*A[r]<(long)1e9){tmp*=A[r];now=now*power(A[r],r-l+1)%mod;ans=ans*now%mod;r++;}now=now*power(tmp,mod-2)%mod;tmp/=A[l];}cout<<ans<<endl;}