結果

問題 No.3413 あわてんぼうのルクくん
コンテスト
ユーザー applejam
提出日時 2025-12-20 03:08:03
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 425 ms / 2,000 ms
コード長 1,087 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,740 ms
コンパイル使用メモリ 334,996 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-20 03:08:16
合計ジャッジ時間 12,452 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vmi = vector<mint>;
using vvmi = vector<vmi>;
using vvvmi = vector<vvmi>;
#define all(a) (a).begin(), (a).end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
ll gcd(ll a, ll b){
    if(a < b)swap(a, b);
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

void solve(){
    ll x, n, d; cin >> x >> n >> d;
    if(gcd(x, d) != 1){
        cout << "inf" << endl;
        return;
    }
    if(x == 1){
        cout << -1 << endl;
        return;
    }
    cout << x*d - d + x*((x-2)/n) << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q; cin >> q;
    while(q--)solve();

    return 0;
}
0