这两个代码有什么区别吗?
查看原帖
这两个代码有什么区别吗?
615328
s3328744976楼主2022/10/23 13:14

求助 RT

80分

#include<bits/stdc++.h>
using namespace std;
long long c,k; 
int main(){
	cin>>c>>k;
	while(c!=1){
		c++;
		if(c%3==0) c/=3;
		k--;
		if(k==0) break;
	}
	cout<<c+k%2;
	return 0;
} 

ac

#include<bits/stdc++.h>
using namespace std;
long long c,k; 
int main(){
	cin>>c>>k;
	while(c!=1 and k>0){
		c++;
		if(c%3==0) c/=3;
		k--;
	}
	cout<<c+k%2;
	return 0;
} 
2022/10/23 13:14
加载中...