結果

問題 No.1047 Zero (Novice)
ユーザー kyo1
提出日時 2020-05-20 10:08:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 333 bytes
コンパイル時間 2,655 ms
コンパイル使用メモリ 190,904 KB
最終ジャッジ日時 2025-01-10 13:20:54
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 1 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t A, B;
  cin >> A >> B;
  if (A * B > 0) {
    cout << -1 << '\n';
  } else {
    int64_t N = B;
    int res = 1;
    while (N != 0) {
      N = N * A + B;
      res++;
    }
    cout << res << '\n';
  }
  return 0;
}
0