結果
問題 | No.1047 Zero (Novice) |
ユーザー |
![]() |
提出日時 | 2020-05-20 10:14:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 493 bytes |
コンパイル時間 | 7,405 ms |
コンパイル使用メモリ | 197,192 KB |
最終ジャッジ日時 | 2025-01-10 13:21:16 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 2 TLE * 1 |
ソースコード
#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 || A == -B) { cout << -1 << '\n'; } else { int64_t N = B; int res = 1; set<int64_t> st; st.insert(N); while (N != 0) { N = N * A + B; if (st.find(N) != st.end()) { cout << -1 << '\n'; return 0; } st.insert(N); res++; } cout << res << '\n'; } return 0; }