結果
| 問題 | No.1047 Zero (Novice) |
| コンテスト | |
| ユーザー |
kyo1
|
| 提出日時 | 2020-05-20 10:14:18 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 493 bytes |
| 記録 | |
| コンパイル時間 | 1,255 ms |
| コンパイル使用メモリ | 215,180 KB |
| 実行使用メモリ | 13,184 KB |
| 最終ジャッジ日時 | 2026-06-10 05:06:46 |
| 合計ジャッジ時間 | 5,311 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 2 TLE * 1 -- * 2 |
ソースコード
#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;
}
kyo1