結果

問題 No.415 ぴょん
ユーザー aaaaaa
提出日時 2018-08-22 18:29:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,267 bytes
コンパイル時間 1,955 ms
コンパイル使用メモリ 93,112 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-26 00:29:37
合計ジャッジ時間 2,413 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>

using namespace std;

int main() {
	int i, j, k;
	long n, d;

	cin >> n >> d;

	long jyo = 0, iti = 0, tugi = 0, sum = 0, cnt = 0;
	vector<long>amari;
	amari.push_back(1);
	cnt++;

	if (n - 1 == d) {
		cout << n - 1 << endl;
		getchar();
		getchar();
		return 0;
	}

	if (n == d) {
		cout << 0 << endl;
		getchar();
		getchar();
		return 0;
	}

	if (n%d == 0) {
		cout << n / d - 1 << endl;
		getchar();
		getchar();
		return 0;
	}
	else {
		cout << n / (n + 1 - (((n - 1) / d)*d + 1)) - 1 << endl;
		getchar();
		getchar();
		return 0;
	}



	while (true) {



		jyo = (n - amari[cnt-1]) / d;
		sum += jyo;
		//amari.push_back()

		iti = jyo * d + amari[cnt -1];

		tugi = d - (n - iti);

		bool flag = false;

		for (i = 0; i < cnt; i++) {
			if (amari[i] == tugi) {
				flag = true;
				break;
			}
		}

		if (flag == false) {
			amari.push_back(tugi);
			cnt++;
			sum++;
		}
		else {
			break;
		}

	}

	cout << sum << endl;




	getchar();
	getchar();
	return 0;
}
0