結果
問題 |
No.1047 Zero (Novice)
|
ユーザー |
![]() |
提出日時 | 2020-07-01 11:34:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 637 bytes |
コンパイル時間 | 1,529 ms |
コンパイル使用メモリ | 165,088 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-13 20:54:23 |
合計ジャッジ時間 | 2,212 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using ll = long long; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int cnt{ 0 }; ll a, b, n{ 0 }; cin >> a >> b; if (a == 0 && b != 0) { cout << "-1\n"; return 0; } while (1) { if ((a * n > 0 && b > 0) || (a * n < 0 && b < 0)) { cnt = -1; break; } n = a * n + b; ++cnt; if (!n) break; } cout << cnt << "\n"; return 0; }