沐咕 @ 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 MLE_Automaton @ 2024-11-08 21:45:21
@沐咕 结束条件是
by 沐咕 @ 2024-11-08 21:45:28
球球了各位大佬,给个代码吧qwq
by Argon_Cube @ 2024-11-08 21:45:42
每次需要插入 set
的是
by DDD_et @ 2024-11-08 21:46:00
@沐咕
纯 WA 啊,那行,等我做一下
by 沐咕 @ 2024-11-08 21:46:10
@Argon_Cube 所以咋改,我要代码qwq
by ran_qwq @ 2024-11-08 21:46:13
@沐咕 出现重复的数不能保证以后的数都是重复的
如10->2->8->6->2->4
注意这个4在出现两次的2之后出现,但它是一个新的数
by __Louis__ @ 2024-11-08 21:46:24
#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.count(x)&&!s.count(y))
break;
s.insert(abs(y - x));
long long tx = x;
x = y;
y = abs(y - tx);
}
cout << s.size() << endl;
return 0;
}
by 沐咕 @ 2024-11-08 21:46:24
@DDD_et OK
by __Louis__ @ 2024-11-08 21:47:00
@沐咕
#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.count(x)&&!s.count(y))
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:47:41
等等,有 bug。