Question for problem 1747B

Правка en2, от yanjiang_01, 2023-03-06 17:23:11

i can't ac it,i don't know why.

my code:

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<map>
using namespace std;
int main() {
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		if(n%2==1){
			cout<<n/2+1<<endl;
			int m = (n-1)*3;
			int i = 6;
			for(;i<=m;i+=6){
				cout<< i-5<<" "<<i<<endl;
			}
			cout<< m+1<<" "<<m+3<<endl;
		}
		else {
			cout<<n/2<<endl;
			int i = 6;
			for(;i<=n*3;i+=6){
				cout<< i-5<<" "<<i<<endl;
			}
		}
	}
    return 0;
}

Standard answer code:

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<map>
using namespace std;
int main() {
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		cout<<n/2+n%2<<endl;
		int l = 1, r = 3*n;
 		while(l < r){
 			cout << l << " " << r << endl;
 			l += 3;
 			r -= 3;
 		}
	}
    return 0;
}

 

 

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский yanjiang_01 2023-03-06 17:23:11 352
en1 Английский yanjiang_01 2023-03-06 17:20:48 1349 Initial revision (published)