結果

問題 No.3179 3 time mod
ユーザー 北杜
提出日時 2025-06-13 22:00:41
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 960 bytes
コンパイル時間 2,634 ms
コンパイル使用メモリ 278,432 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-13 22:00:52
合計ジャッジ時間 6,672 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other TLE * 1 -- * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
using ll = long long;
const ll INF32 = 2e9;
const ll INF64 = 4e18;
using namespace atcoder;
using mint = modint998244353;

// 勘.

void printYN(bool ok){
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return;
}

int main() {    
    ll N, P, Q, R, A, B, C;
    cin >> N >> P >> Q >> R >> A >> B >> C;
    while(A!=B||B!=C){
        if(A<B){
            A+=P;
        }
        if(B<A){
            B+=Q;
        }
        if(B<C){
            B+=Q;
        }
        if(C<B){
            C+=R;
        }
        if(C<A){
            C+=R;
        }
        if(A<C){
            A+=P;
        }
        if(A>N||B>N||C>N){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (N-A)/lcm(P, lcm(Q, R))+1 << endl;
    return 0;
}
0