結果
問題 | No.1330 Multiply or Divide |
ユーザー |
|
提出日時 | 2021-01-08 21:31:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 445 bytes |
コンパイル時間 | 902 ms |
コンパイル使用メモリ | 68,252 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-16 18:19:01 |
合計ジャッジ時間 | 4,318 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 WA * 1 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream>#include<algorithm>using namespace std;int N,M,P;int A[2<<17];main(){cin>>N>>M>>P;int mM=M;for(int i=0;i<N;i++){cin>>A[i];mM=min(mM,M/A[i]);}if(mM==0){cout<<1<<endl;return 0;}int ans=1e9;for(int i=0;i<N;i++){int a=A[i],c=0;while(a%P==0)a/=P,c++;if(a==1)continue;int d=0;long t=1;while(t<=mM)t*=a,d++;ans=min(ans,d*(c+1)+1);}cout<<(ans==(int)1e9?-1:ans)<<endl;}