結果

問題 No.1047 Zero (Novice)
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2020-05-09 13:13:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,926 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 197,944 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-19 05:24:45
合計ジャッジ時間 5,266 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
ll mul(ll a, ll b) { 
	if (a < 0) a *= -1;
	if (b == 0) return 0;
	if (0 < b) {
		if (infl / a < b) return infl; return min(infl, a * b);
	}
	else {
		if (infl / a < -b) return -infl; return max(-infl, a * b);
	}
}
ll add(ll a, ll b) {
	ll res = a + b;
	if (res < -infl) return -infl;
	if (infl < res) return infl;
	return res;
}
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














ll A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B;

	ll N = 0;
	rep(i, 1, 101) {
		N = add(mul(N, A), B);

		if (N == 0) {
			cout << i << endl;
			return;
		}
	}
	cout << -1 << endl;
}





0