Please read the new rule regarding the restriction on the use of AI tools. ×

Question for problem 1747B

Revision en1, by yanjiang_01, 2023-03-06 17:20:48

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; }

 

 

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English yanjiang_01 2023-03-06 17:23:11 352
en1 English yanjiang_01 2023-03-06 17:20:48 1349 Initial revision (published)