結果

問題 No.2259 Gas Station
ユーザー kpinkcat
提出日時 2023-09-24 23:06:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 668 bytes
コンパイル時間 1,892 ms
コンパイル使用メモリ 198,924 KB
最終ジャッジ日時 2025-02-17 02:13:34
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
#include<string>
using ll = long long;
using namespace std;


int main()
{
    ll l, r, c, rest = 0, min1 = 1001;
    cin >> l >> r >> c;
    set<ll> st;
    for (ll i = l; i <= r; i++){
        rest = 1000 - i*c%1000;
        if (rest == 1000){
            cout << 0 << endl;
            return 0;
        }
        min1 = min(min1, rest);
        if (!st.count(rest)) st.insert(rest);
        else {
            cout << min1 << endl;
            return 0;
        }
    }
    cout << min1 << endl;
}

0