結果

問題 No.1047 Zero (Novice)
ユーザー deuteridayo
提出日時 2020-05-21 12:17:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 399 bytes
コンパイル時間 1,596 ms
コンパイル使用メモリ 173,676 KB
実行使用メモリ 149,284 KB
最終ジャッジ日時 2024-10-01 23:57:08
合計ジャッジ時間 5,280 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 1 TLE * 1 -- * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    long a,b;
    cin >> a >> b;
    map<long,bool>m;
    int ans = 1;
    long n = b;
    if(a*b > 0){
        n=0;
        ans = -1;
    }
    while(n != 0){
        if(m[n]){
            ans = -1;
            break;
        }else{
            m[n] = true;
        }
        n = a*n + b;
        ans++;
    }
    cout << ans << endl;
    
}
0