結果
問題 | No.1330 Multiply or Divide |
ユーザー |
|
提出日時 | 2021-01-08 21:31:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,105 bytes |
コンパイル時間 | 1,911 ms |
コンパイル使用メモリ | 191,968 KB |
最終ジャッジ日時 | 2025-01-17 11:17:37 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 39 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:29:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | int n; ll m, p; scanf("%d%lld%lld", &n, &m, &p); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:30:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 30 | REP(i, n) scanf("%lld", a+i); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i, n) FOR(i, 0, (n)) #define FOR(i, a, b) for(int i=(a); i<(b); i++) #define LAR(a, b) ((a)=max((a),(b))) #define SML(a, b) ((a)=min((a),(b))) using ll = long long; using ld = long double; using vi = vector<int>; using vl = vector<ll>; using pii = pair<int, int>; using vpii = vector<pair<int, int>>; template<typename T> using pque = priority_queue<T, vector<T>, greater<T>>; #define PB push_back #define EB emplace_back #define MP make_pair #define ALL(a) (a).begin(), (a).end() #ifdef LOCAL_DEBUG #define DEBUG(...) printf(__VA_ARGS__) #else #define DEBUG(...) #endif ll a[212345]; ll b[212345]; int main(){ int n; ll m, p; scanf("%d%lld%lld", &n, &m, &p); REP(i, n) scanf("%lld", a+i); REP(i, n){ b[i] = a[i]; while(b[i] % p == 0) b[i] /= a[i]; } ll *y = max_element(a, a+n); ll *z = max_element(b, b+n); int ans = 0; ll x = 1; while(x <= m){ if(x * *y > m) { ans++; break; } if(*z == 1) { ans = -1; break; } x *= *(z-b+a); ans++; while(x % p == 0){ x /= p; ans++; } } printf("%d\n", ans); }