結果
問題 | No.810 割った余りの個数 |
ユーザー |
![]() |
提出日時 | 2019-04-12 21:26:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,112 bytes |
コンパイル時間 | 1,043 ms |
コンパイル使用メモリ | 107,520 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 17:07:08 |
合計ジャッジ時間 | 2,029 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
/* ---------- STL Libraries ---------- */// IO library#include <cstdio>#include <fstream>#include <iomanip>#include <ios>#include <iostream>// algorithm library#include <algorithm>#include <cmath>#include <numeric>#include <random>#include <cstring>// container library#include <array>#include <bitset>#include <deque>#include <map>#include <unordered_map>#include <queue>#include <set>#include <string>#include <tuple>#include <vector>#include <stack>/* ---------- Namespace ---------- */using namespace std;/* ---------- Type ---------- */using ll = long long;#define int ll#define P pair<ll, ll>/* ---------- Constants */const double PI = 3.141592653589793238462643383279;const ll MOD = 1e9 + 7;const int INF = 1LL << 55;/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */signed main() {int L, R, M;cin >> L >> R >> M;int l = L % M;int r = R % M;if (R - L + 1 >= M) {cout << M << endl;} else if (r >= l) {cout << r - l + 1 << endl;} else {cout << (M - 1 - l + 1) + (r + 1) << endl;}return 0;}