結果

問題 No.1048 Zero (Advanced)
ユーザー nanophoto12nanophoto12
提出日時 2020-05-08 23:14:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 2,271 bytes
コンパイル時間 2,524 ms
コンパイル使用メモリ 222,196 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 03:29:10
合計ジャッジ時間 3,428 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,376 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 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

const ll mod = 1e9 + 7;

const ll INF = 1e15;

class Primes {
private:
	vector<int> Prime_Number;
	vector<bool> is_prime_;
public:
	Primes(int N) {
		is_prime_.resize(N + 1, true);
		is_prime_[0] = is_prime_[1] = false;
		for (int i = 0; i < N + 1; i++) {
			if (is_prime_[i]) {
				Prime_Number.push_back(i);
				for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
			}
		}
	}
	int operator[](int i) { return Prime_Number[i]; }
	int size() { return Prime_Number.size(); }
	int back() { return Prime_Number.back(); }
	bool isPrime(int q) { return is_prime_[q]; }
};

class Divisor {
private:
	vector<ll> F;
	vector<pair<ll, ll>> pfactorize;
public:
	Divisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
		Primes p((ll)sqrt(N) + 1);
		for (int i = 0; i < p.size(); i++) {
			pfactorize.emplace_back(p[i], 0);
			while (N % p[i] == 0) {
				N /= p[i];
				pfactorize.back().second++;
			}
			if (pfactorize.back().second == 0) pfactorize.pop_back();
		}
		if (N > 1) pfactorize.emplace_back(N, 1);
	}
	int size() { return F.size(); }
	const vector<pair<ll, ll>>& pfac() { return pfactorize; } const
		ll operator[](int k) { return F[k]; }
};

int main() {
	ll l, r, m, k;
	cin >> l >> r >> m >> k;
	if (k == 0 || l == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (l == 1) {
		if (m <= k) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	Divisor md(m);
	Divisor kd(k);
	map<ll, ll> mmap;
	for (auto p : md.pfac()) {
		mmap[p.first] = p.second;
	}
	ll unit = 1;
	for (auto p : kd.pfac()) {
		auto a = p.second - mmap[p.first];
		for (int j = 0; j < a; j++) {
			unit *= p.first;
		}
	}
	auto i = m * unit / k;
	auto left = (l-1) / i;
	auto right = r / i;
	if (left != right) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}
0