結果

問題 No.3022 一元一次式 mod 1000000000
ユーザー pitP
提出日時 2025-02-14 22:37:32
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 6,051 ms
コンパイル使用メモリ 332,580 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-14 22:37:41
合計ジャッジ時間 7,438 ms
ジャッジサーバーID
(参考情報)
judge7 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

#ifdef LOCAL
#  include <debug_print.hpp>
#  define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define debug(...) (static_cast<void>(0))
#endif

long long solve() {
    long long N, S, K;
    N = 1e9;
    cin >> K >> S;

    if(S % N == 0 && K % N == 0){
        return 1;
    }
    if(K % N == 0 && S % N){
        return -1;
    }

    S %= N;
    K %= N;
    debug(S, K, N);

    auto p = crt({0, N - S}, {K, N});
    if (p.second == 0) return -1;
    debug(p, N);
    return p.first / K;
}

int main(){
    int T;
    cin >> T;
    while (T--) cout << solve() << endl;
}
0