求正确性证明
查看原帖
求正确性证明
1115904
malinhao45楼主2024/11/6 22:26

赛时代码,一年过去了,还是不知道为什么AC了

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int a[1000000];
int main() {
	cin>>n;
	int cnt=1;
	int ans2=0;
	bool cmp=true;
	int c=0;
	for(int j=1; j<=n; j++) {
		for(int i=cnt; i<=n; i+=3) {
			if(i==n) {
				cmp=false;
				ans2=j;
			}
			cnt++;
		}
		if(cmp==false) {
			break;
		}
	}
	cnt=1;
	int t=0;
	for(int j=1; j<=n; j++) {
		for(int i=cnt; i<=n; i+=3) {
			t++;
			cnt++;
		}
		c++;
		if(t==n) {
			break;
		}

	}
	cout<<c<<" "<<ans2;
	return 0;
}
2024/11/6 22:26
加载中...