結果

問題 No.3179 3 time mod
ユーザー SnowBeenDiding
提出日時 2025-06-13 21:32:45
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 5,552 ms
コンパイル使用メモリ 335,496 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-06-14 01:39:03
合計ジャッジ時間 6,871 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;

typedef long long ll;

using mint = modint998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(12);
    ll n, p, q, r, a, b, c;
    cin >> n >> p >> q >> r >> a >> b >> c;
    vector<ll> M = {p, q, r};
    vector<ll> R = {a, b, c};
    auto P = crt(R, M);
    pair<ll, ll> zero = {0, 0};
    if (P == zero) {
        cout << 0 << endl;
        return 0;
    }
    if (P.first == 0) {
        cout << n + 1 << endl;
        return 0;
    }
    ll ans = n - P.first;
    if (ans < 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << ans / P.second + 1 << endl;
}
0