結果

問題 No.3413 あわてんぼうのルクくん
コンテスト
ユーザー The Forsaking
提出日時 2025-12-21 23:21:13
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 474 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,006 ms
コンパイル使用メモリ 194,600 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-12-21 23:21:20
合計ジャッジ時間 5,398 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |     scanf("%d", &m);
      |     ~~~~~^~~~~~~~~~
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         scanf("%d%d%d", &x, &n, &d);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
const int N = 2000010, MOD = 998244353, INF = 0x3f3f3f3f;
int n, m, w[N];


int main() {
    scanf("%d", &m);
    while (m--) {
        int x, n, d;
        scanf("%d%d%d", &x, &n, &d);
        if (__gcd(x, d) > 1) puts("inf");
        else printf("%lld\n", (ll)x * d - x - d + (ll)(x - 2) / n * x + x ? (ll)x * d - x - d + (ll)(x - 2) / n * x + x : -1);
    }
    return 0;
}
0