我是靠谱客的博主 淡淡汽车,最近开发中收集的这篇文章主要介绍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 Codeforces Round 58 (Rated for Div. 2) A. Minimum Integer题解AC代码所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复