結果

問題 No.1047 Zero (Novice)
ユーザー take000take000
提出日時 2020-05-08 21:48:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 1,396 ms
コンパイル使用メモリ 163,320 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-17 02:32:12
合計ジャッジ時間 3,267 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,500 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    ll A, B, now = 0;
    cin >> A >> B;

    if (B == 0)
        cout << 1;
    else if (A >= 1)
        cout << -1;
    else if (A == -1)
        cout << 2;
    else {
        int ans = 0;
        do {
            now = A * now + B;
            cout << now << endl;
            ++ans;
            if (ans == 100000) {
                ans = -1;
                break;
            }
        } while (now != 0);
        cout << ans;
    }
    cout << endl;

    return 0;
}
0