結果

問題 No.1330 Multiply or Divide
ユーザー XDXD
提出日時 2021-11-12 20:31:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,591 bytes
コンパイル時間 1,385 ms
コンパイル使用メモリ 171,184 KB
実行使用メモリ 57,728 KB
最終ジャッジ日時 2024-11-25 10:00:40
合計ジャッジ時間 4,327 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 45 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define forn(i,s,t) for(register int i=(s); i<=(t); ++i)
#define forl(i,s,t) for(register i64 i=(s); i<=(t); ++i)
#define form(i,s,t) for(register int i=(s); i>=(t); --i)
#define rep(i,s,t) for(register int i=(s); i<(t); ++i)
#define IT(u) for(register int i=G[u]; i; i=E[i].nxt)
using namespace std;
namespace FASTIO {
	const int SIZ = 1 << 26 | 1;
	char ibuf[SIZ], obuf[SIZ], *iS = ibuf, *iT = ibuf, *oS = obuf, *oT = obuf + SIZ - 1, qwq[60], qaq;
	#define gc() (iS == iT && (iT = (iS = ibuf) + fread(ibuf, 1, SIZ, stdin), iS == iT) ? EOF : *iS++)
	template<typename T>
	inline void Rdn(T& A) {
		register bool fl = 0;
		register char ch = gc(); A = 0;
		while(!isdigit(ch)) fl = (ch == '-'), ch = gc();
		while(isdigit(ch)) A = (A * 10) + (ch & 15), ch = gc();
		fl && (A = -A);
	}
	inline void Rdn(char& c) {while((c = gc()) == ' ' || c == '\n' || c == '\r');}
	inline void Rdn(char* s) {
		while((*s = gc()) == ' ' || *s == '\n' || *s == '\r') ;
		if(*s == EOF) return ;
		while(*s != ' ' && *s != '\n' && *s != '\r' && *s != EOF) *(++s) = gc();
		*s = 0;
	}
	template<typename T, typename ...U>
	inline void Rdn(T& A, U& ...B) {Rdn(A), Rdn(B...);}
	inline void flush() {fwrite(obuf, 1, oS - obuf, stdout), oS = obuf;}
	inline void pc(char c) {*oS ++ = c; if(oS == oT) flush();}
	template<typename T>
	inline void Wtn(T A) {
		if(!A) return pc('0'); if(A < 0) pc('-'), A = -A;
		while(A) qwq[++qaq] = A % 10 + '0', A /= 10;
		while(qaq) pc(qwq[qaq -- ]);
	}
	inline void Wtn(char A) {pc(A);}
	inline void Wtn(char *s) {while(*s) pc(*s), ++s;}
	inline void Wtn(const char *s) {while(*s) pc(*s), ++s;}
	template<typename T, typename ...U>
	inline void Wtn(T A, U ...B) {Wtn(A), Wtn(B...);}
#undef gc
}
using FASTIO :: Rdn;
using FASTIO :: Wtn;
using FASTIO :: flush;
typedef long long i64;
typedef double f64;
typedef unsigned long long u64;
typedef pair<i64, i64> pii;
typedef pair<int, u64> piu;
const int N = 2e5 + 5;
const i64 INF = 1e18;
inline void init() {}
int n, m, P, a[N], k[N], x[N], f[N << 6], Mx, Mt[N];
inline void solve() {
	Rdn(n, m, P);
	forn (i, 1, n) Rdn(a[i]); sort (a + 1, a + n + 1);
	forn (i, 1, n) {
		x[i] = a[i];
		while (x[i] % P == 0) k[i] ++ , x[i] /= P;
		Mx = max(Mx, x[i]), Mt[k[i]] = max(Mt[k[i]], x[i]);
	}
	if (Mx <= 1) return Wtn("-1\n");
	memset(f, -1, sizeof f);
	f[0] = 1; int res = 0;
	while (1ll * f[res] * a[n] <= m) {
		forn (d, 0, 63) if (Mt[d]) f[res + d + 1] = max(f[res + d + 1], f[res] * Mt[d]); ++res;
	}
	Wtn(res + 1, '\n');
}
int Trd;
int main() {
	Trd = 1;
	while(Trd--) init(), solve(); flush();
	return 0;
}
0