Question for problem 1747B

Правка en1, от 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; }

 

 

История

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