結果

問題 No.415 ぴょん
ユーザー nksk38
提出日時 2017-07-05 12:19:30
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 540 bytes
コンパイル時間 861 ms
コンパイル使用メモリ 73,512 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 14:54:04
合計ジャッジ時間 1,447 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;

ll gcd(ll a, ll b) {
	while (b != 0) {
		a = a % b;
		swap(a, b);
	}
	return a;
}

int main()
{
	ll N, D,ans;
	cin >> N >> D;

	if (N == D)
		ans = 0;
	else if (N % D == 0)
		ans = N / D - 1;
	else
		ans = (N*D /gcd(N, D))/D -1;

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