結果

問題 No.415 ぴょん
ユーザー GrayCoder
提出日時 2018-08-14 05:02:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 533 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 167,780 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 08:36:03
合計ジャッジ時間 4,304 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int gcd(int m, int n) {
	if ((0 == m) || (0 == n))
		return 0;
	while (m != n) {
		if (m > n) m = m - n;
		else n = n - m;
	}
	return m;
}

int lcm(int m, int n) {
	if ((0 == m) || (0 == n))
		return 0;
	return ((m / gcd(m, n)) * n);
}

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int N, D, ans;
  cin >> N >> D;

  ans = lcm(N, D) / D - 1;
  cout << ans << endl;
  return 0;
}
0