結果

問題 No.1047 Zero (Novice)
ユーザー kcz146
提出日時 2020-06-17 01:54:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 192,664 KB
最終ジャッジ日時 2025-01-11 04:48:27
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll a, b;
    cin >> a >> b;

    ll n = 0, i = 0;
    do {
        n = a*n + b;
        i++;
    } while(-1e10 < n && n < 1e10 && n != 0 && i < 1e6);

    cout << (n == 0 ? i : -1) << endl;
}
0