結果

問題 No.415 ぴょん
ユーザー めうめう🎒めうめう🎒
提出日時 2017-02-01 18:04:08
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 820 bytes
コンパイル時間 1,865 ms
コンパイル使用メモリ 77,832 KB
実行使用メモリ 168,840 KB
最終ジャッジ日時 2023-08-25 17:02:09
合計ジャッジ時間 3,948 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	ll n, d, ans = 0;
	cin >> n >> d;
	set<ll> used;
	ll now = 0;
	while(true){
		if(used.find(now) != used.end()) break;
		used.insert(now);

		if((n - now) % d == 0){
			ans += (n - now) / d;
			now += ((n - now) / d) * d;
		}else{
			ans += (n - now) / d + 1;
			now += ((n - now) / d + 1) * d;
		}

		now %= n;

		// cout << ":" << now << "-" << ans << endl;
	}

	cout << ans - 1 << endl;
	return 0;
}
0