我是靠谱客的博主 淡淡汽车,这篇文章主要介绍Educational Codeforces Round 58 (Rated for Div. 2) A. Minimum Integer题解AC代码,现在分享给大家,希望可以做个参考。

题解

题目大意 让你找到最小的能被d整除且不在[l, r]范围内的数字

考虑小于l的情况 最小为d 大于r的情况 (r/d+1)*d第一个大于r的d的倍数

AC代码

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main()
{
#ifdef LOCAL
//freopen("C:/input.txt", "r", stdin);
#endif
int T;
cin >> T;
while (T--)
{
ll l, r, d;
cin >> l >> r >> d;
if (d < l)
cout << d << endl;
else
cout << (r / d + 1) * d << endl;
}
return 0;
}

最后

以上就是淡淡汽车最近收集整理的关于Educational Codeforces Round 58 (Rated for Div. 2) A. Minimum Integer题解AC代码的全部内容,更多相关Educational内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(63)

评论列表共有 0 条评论

立即
投稿
返回
顶部