結果
問題 | No.1330 Multiply or Divide |
ユーザー |
👑 ![]() |
提出日時 | 2021-01-08 21:38:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 507 bytes |
コンパイル時間 | 1,824 ms |
コンパイル使用メモリ | 191,720 KB |
最終ジャッジ日時 | 2025-01-17 11:27:57 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 WA * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%llu%llu%llu",&N,&M,&P); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:14:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | ULL a; scanf("%llu",&a); | ~~~~~^~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) ULL N,M,P; ULL maxA,maxB; int main(){ scanf("%llu%llu%llu",&N,&M,&P); maxA=1; maxB=1; rep(i,N){ ULL a; scanf("%llu",&a); maxA=max(maxA,a); while(a%P==0) a/=P; maxB=max(maxB,a); } ULL x=1; if(maxA>=M){ printf("1\n"); return 0; } if(maxB==1){ printf("-1\n"); return 0; } ULL ans=1; while(x*maxA<M){ x*=maxB; ans++; } printf("%llu\n",ans); return 0; }