結果

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

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
#define rep1(a) for (int z = 0; z < a; z++)
#define rep2(i, a) for (ll i = 0; i < a; i++)
#define rep3(i, a, b) for (int i = a; i < b; i++)
#define rep4(i, a, b, c) for (int i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define ALL(x) std::begin(x), std::end(x)
#define YN(x) cout << (x ? "Yes" : "No") << endl;
#define popc(x) __builtin_popcount(x)
#define cmp(x, l, r) ((l <= x) && (x <= r))
#define rrep(i, a) for (int i = (a)-1; i >= 0; i--)
#define ll long long
void solve() {
  ll X,N,D;cin>>X>>N>>D;
  if(gcd(X,D)>1){
    cout<<"inf"<<endl;
    return;
  }
  auto ans=(X-2)/N*X+D*(X-1);
  if(ans==0)ans=-1;
  cout<<ans<<endl;
}
int main() {
  int T;
  cin >> T;
  // T=1;
  rep(T) solve();
}
0