题目:两个闹钟
能这样写吗?
#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;
}