結果
| 問題 | No.415 ぴょん |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-07-05 12:19:30 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 540 bytes |
| 記録 | |
| コンパイル時間 | 531 ms |
| コンパイル使用メモリ | 95,244 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-13 03:15:17 |
| 合計ジャッジ時間 | 1,620 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#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;
}