T1怪异解法,为什么能过...
查看原帖
T1怪异解法,为什么能过...
1013142
Chizuru_Ichinose楼主2023/10/31 19:04
#include<bits/stdc++.h>
using namespace std;
long long n,sum;
int main(){
	cin>>n;
	int temp,T=n,pos=0;
	while(n/3>=1){
		temp=n/3;
		if(temp*3!=n) temp++;
		n-=temp;
		sum++;
		if((T-1)%3==0 && T>=0){
			T=-1;
			pos=sum;
		}
		else if(T>=0){
			T-=temp;
		}
	}
	if(T>=0){
		pos=sum+T;
	}
	sum+=n;
	cout<<sum<<" "<<pos;
}
2023/10/31 19:04
加载中...