沐咕 @ 2024-11-08 21:34:30
#include <bits/stdc++.h>
using namespace std;
long long a, b;
set<long long> s;
int main()
{
cin >> a >> b;
s.insert(a);
s.insert(b);
long long x = a, y = b;
while (true)
{
if (s.find(abs(y - x)) != s.end())
break;
s.insert(abs(y - x));
x = y;
y = abs(y - x);
}
cout << s.size() << endl;
return 0;
}
by __Louis__ @ 2024-11-08 21:41:56
哦没事了,我看错了
by DDD_et @ 2024-11-08 21:42:12
应该是改成上面这样吧……(心虚)
by 沐咕 @ 2024-11-08 21:42:23
@Louis T 没飞,活着,只有 WAqwq
by MLE_Automaton @ 2024-11-08 21:42:47
@沐咕 还有你这代码样例都不能过吧
by 沐咕 @ 2024-11-08 21:43:38
@DDD_et
10 分
#include <bits/stdc++.h>
using namespace std;
long long a, b;
set<long long> s;
int main()
{
cin >> a >> b;
s.insert(a);
s.insert(b);
long long x = a, y = b;
while (true)
{
if (s.find(abs(y - x)) != s.end())
break;
s.insert(abs(y - x));
long long tx = x;
x = y;
y = abs(y - tx);
}
cout << s.size() << endl;
return 0;
}
by __Louis__ @ 2024-11-08 21:43:52
@沐咕
建议用 count,会更好一点
还有,不一定出现了两次就一定会结束循环,要保证三个数都出现过了。/
by DDD_et @ 2024-11-08 21:44:15
@沐咕
那是 TLE 吗
by 沐咕 @ 2024-11-08 21:44:32
所以怎么改!!!qwq
by Argon_Cube @ 2024-11-08 21:44:46
@沐咕 显然要
by 沐咕 @ 2024-11-08 21:45:02
@DDD_et 啥都没有,纯 WA.。。