結果

問題 No.1048 Zero (Advanced)
ユーザー vtr_codervtr_coder
提出日時 2020-05-08 22:35:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,406 bytes
コンパイル時間 1,194 ms
コンパイル使用メモリ 163,548 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 03:12:02
合計ジャッジ時間 1,920 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010


// ユークリッドの互除法の変形
template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }
// 最小公倍数
template <typename T> T lcm(T a, T b) { return a / gcd(a,b) * b; }

ll func(ll a, ll b, ll n) {
    ll lcmab = lcm(a, b);
    return lcmab * ((n + lcmab - 1) / lcmab);
}

signed main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int L, R, M, K;
    cin >> L >> R >> M >> K;
    if(K == 0 || (L <= M && M <= R)) {
        printf("Yes\n");
        return 0;
    }
    if(L % M > R % M) {
        printf("Yes\n");
        return 0;
    }
    L %= M;
    R %= M;
    if(L == 0) {
        printf("Yes\n");
        return 0;
    }

    int cand = func(1, M, L * K);
    if(cand <= R * K) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }


    return 0;
}
0