結果
問題 | No.810 割った余りの個数 |
ユーザー |
![]() |
提出日時 | 2019-05-24 01:46:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,165 bytes |
コンパイル時間 | 953 ms |
コンパイル使用メモリ | 96,864 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 09:59:58 |
合計ジャッジ時間 | 1,777 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include <iostream>#include <cmath>#include <vector>#include <string>#include <map>#include <algorithm>#include <numeric>#include <fstream>#include <iomanip>typedef long double ld;typedef long long ll;const ll INF = (ll)1e18 + 1;const ll MOD = 1e9 + 7;// Splitnamespace util {std::vector< std::string > split(std::string s, char delimiter){std::vector< std::string > vs;std::string sub;for (auto c : s) {if (c == delimiter) vs.push_back(sub), sub.clear();else sub += c;}vs.push_back(sub);return vs;}} // namespace util// Minimum, Maximumtemplate<class T> T minimum(T head, T tail) { return std::min(head, tail); }template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }template<class T> T maximum(T head, T tail) { return std::max(head, tail); }template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }// Outputtemplate<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p){return os << p.first << " " << p.second;}template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v){for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }return os;}template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp){ll i = 0;for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}return os;}void print(){ std::cout << std::endl; }template<typename H> void print(H head) { std::cout << head << std::endl; }template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }int main(){std::cin.tie(nullptr);std::ios::sync_with_stdio(false);ll L, R, M;std::cin >> L >> R >> M;ll x = L % M;ll y = R % M;if (L == R) {print(1);return 0;}if (y == x) {print(M);return 0;}if (R - L >= M - 1) {print(M);return 0;}if (y < x) y += M;ll ans = y - x + 1;print(ans);return 0;}