結果

問題 No.1330 Multiply or Divide
ユーザー TonalidadeHidricaTonalidadeHidrica
提出日時 2021-01-08 21:31:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,105 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 199,932 KB
実行使用メモリ 6,912 KB
最終ジャッジ日時 2024-04-28 02:08:14
合計ジャッジ時間 4,358 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 30 ms
6,784 KB
testcase_02 AC 2 ms
5,376 KB
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 28 ms
6,912 KB
testcase_07 WA -
testcase_08 AC 36 ms
6,784 KB
testcase_09 AC 37 ms
6,912 KB
testcase_10 AC 36 ms
6,784 KB
testcase_11 AC 34 ms
6,784 KB
testcase_12 AC 36 ms
6,784 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 32 ms
6,912 KB
testcase_19 AC 33 ms
6,912 KB
testcase_20 AC 33 ms
6,784 KB
testcase_21 AC 33 ms
6,912 KB
testcase_22 AC 33 ms
6,912 KB
testcase_23 AC 34 ms
6,912 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 25 ms
6,016 KB
testcase_35 AC 8 ms
5,376 KB
testcase_36 AC 23 ms
5,760 KB
testcase_37 AC 20 ms
5,504 KB
testcase_38 AC 14 ms
5,376 KB
testcase_39 AC 10 ms
5,376 KB
testcase_40 AC 12 ms
5,376 KB
testcase_41 AC 7 ms
5,376 KB
testcase_42 AC 19 ms
5,376 KB
testcase_43 AC 21 ms
5,760 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
}
0