結果

問題 No.2259 Gas Station
ユーザー mtrh
提出日時 2023-04-07 21:30:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 1,881 ms
コンパイル使用メモリ 195,436 KB
最終ジャッジ日時 2025-02-12 00:33:22
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ll L, R, C;
    cin >> L >> R >> C;
    vector<bool> seen(1000);
    ll ans = 1000;
    ll now = C * L % 1000;
    for (ll i = L; i <= R; i++) {
        if (seen[now]) break;
        seen[now] = true;
        if (now == 0) {
            ans = 0;
        } else {
            ans = min(ans, 1000 - now);
        }
        now += C;
        now %= 1000;
    }
    cout << ans << endl;
    return 0;
}
0