题解:P11310 无穷的迭代器

· · 题解

upd 2025.1.16:感谢@Vct14 大佬的提醒,代码不小心粘错了,已改正!

这道题貌似光找规律不行,也可能是我太菜了。

提交记录

设 $t=r$ 的分母,每操作一次相当于 $t$ 乘上 $t/2+1$。当 $t$ 为偶数时输出次数即可。 ## code: ```cpp #include<bits/stdc++.h> #define LL long long using namespace std; int T; LL n; int main(){ cin >> T; while(T--){ cin >> n; if(n == 0) cout << "NO!\n"; else{ int ans = 1; while(n % 2 == 0) ans++, n /= 2; cout << ans << "\n"; } } return 0; } ```