题解
2025-04-29 12:33:55
发布于:广东
13阅读
0回复
0点赞
按照题意,使用 if else
模拟。
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
int cur = 1092;
for(int i = 1; i <= n; i++){
if(cur > 1093) cur = 1092;//如果当前的值大于1093就赋值为1092
else{
if(cur % 2 == 1) cur *= 2;//否则如果是奇数就乘2
else cur--;//是偶数就减1
}
}
cout << cur;
return 0;
}
全部评论 1
考古
2025-04-30 来自 浙江
0?我不是最近才发的吗
2025-04-30 来自 广东
0过一天了,考古。
2025-04-30 来自 浙江
0
有帮助,赞一个