結果

問題 No.1330 Multiply or Divide
ユーザー Cyclone28Cyclone28
提出日時 2021-01-08 22:08:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 801 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 168,424 KB
実行使用メモリ 7,288 KB
最終ジャッジ日時 2023-08-10 09:51:43
合計ジャッジ時間 8,871 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 34 ms
6,664 KB
testcase_07 WA -
testcase_08 AC 88 ms
7,176 KB
testcase_09 AC 87 ms
6,928 KB
testcase_10 AC 85 ms
7,160 KB
testcase_11 AC 83 ms
7,256 KB
testcase_12 AC 84 ms
7,288 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,376 KB
testcase_17 WA -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 1 ms
4,376 KB
testcase_25 RE -
testcase_26 AC 2 ms
4,376 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int n, m, p;
  cin >> n >> m >> p;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<int> r;
  bool flag = true, flag2 = true;
  for(int i = 0; i < n; i++) {
    if(a[i] % p != 0) flag = false;
    if(a[i] % p == 0) r.push_back(a[i]);
    if(a[i] != 1) flag2 = false;
  }
  long long t = *max_element(r.begin(), r.end());
  if(t > m){
    cout << 1 << endl;
    return 0;
  }
  if(flag || flag2){
    cout << -1 << endl;
    return 0;
  }
  vector<int> b;
  for(int i = 0; i < n; i++){
    if(a[i] % p != 0) b.push_back(a[i]);
  }
  long long s = *max_element(b.begin(), b.end());
  int ans = 0;
  long long q = 1;
  while(q <= m){
    q *= s;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
0