i can't ac it,i don't know why.
my code:
include
include
include
include
include
include
include
include
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
include
include
include
include
include
include
include
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; } // 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; }