题解 | 小红的正整数构造
小红的正整数构造
https://www.nowcoder.com/practice/7aa37cbc28034fe5af562ec7e44d1e76
//算法练习No.14
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int l,r,x;
int y{-1};
cin >> l >> r >> x;
for(int i = l;i<=r;i++)
{
if(i % x == 0)
{
y = i;
break;
}
}
cout << ((y == -1)?-1:y) << endl;
}
// 64 位输出请用 printf("%lld")

查看12道真题和解析