結果
問題 | No.1330 Multiply or Divide |
ユーザー | ineedyourlovep |
提出日時 | 2021-01-08 22:33:07 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 961 bytes |
コンパイル時間 | 1,757 ms |
コンパイル使用メモリ | 176,792 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-04-28 03:58:23 |
合計ジャッジ時間 | 7,938 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | TLE | - |
testcase_02 | WA | - |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 40 ms
5,376 KB |
testcase_07 | WA | - |
testcase_08 | TLE | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
ソースコード
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; set<ll> prime_factor(ll n){ set<ll> pf; //if(n == 1) pf.push_back(P(1, 1)); for(ll i = 2; i*i <= n; i++){ if(n%i == 0){ while(n%i == 0){ n /= i; } pf.insert(i); } } if(n != 1) pf.insert(n); return pf; } int main() { ll n, m, p; cin >> n >> m >> p; vector<ll> a(n); rep(i, 0, n) cin >> a[i]; sort(a.begin(), a.end()); int cnt = 0; ll mx = 0; rep(i, 0, n){ set<ll> pf = prime_factor(a[i]); if(pf.find(p) != pf.end()) continue; mx = max(mx, a[i]); } if(mx == 0){ cout << -1 << endl; return 0; } ll x = 1; while(x <= m){ cnt++; if(x*a[n-1] > m) break; else x *= mx; } cout << cnt << endl; return 0; }