题目求助......
  • 板块灌水区
  • 楼主molly1212
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/8/16 17:07
  • 上次更新2024/8/16 20:45:16
查看原帖
题目求助......
556017
molly1212楼主2024/8/16 17:07

题目:两个闹钟


能这样写吗?

#include <bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main()
{
	cin >> a >> b >> c >> d;
	for (int i = 0;i <= 100000;i++)
	{
		int j = a+b*i-c;
		if (j % d == 0) j %= d;
		else continue;
		cout << a+b*i << endl;
		return 0;
	}
	cout << -1 << endl;
	return 0;
}
2024/8/16 17:07
加载中...