結果
| 問題 |
No.415 ぴょん
|
| ユーザー |
okayunonaha
|
| 提出日時 | 2016-08-27 02:46:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 406 bytes |
| コンパイル時間 | 457 ms |
| コンパイル使用メモリ | 58,600 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 14:43:18 |
| 合計ジャッジ時間 | 1,296 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) {
if (x < y) swap(x, y);
int tmp;
while (y) {
tmp = y;
y = x % y;
x = tmp;
}
return x;
}
ll lcm(ll x, ll y) {
if (x < y) swap(x, y);
return (x * y / gcd(x, y));
}
int main(void) {
int N, D;
cin.tie(0);
cin >> N >> D;
cout << lcm(N, D)/D - 1 << endl;
return 0;
}
okayunonaha