标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4605 Accepted Submission(s):
2148
1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 int main() 5 { 6 int text, i, n, k, j; 7 int a[5050], b[5050]; 8 scanf("%d", &text); 9 while(text--) 10 { 11 scanf("%d", &n); 12 for(i=1; i<=n; i++) 13 { 14 a[i] = i; 15 b[i] = 0; 16 } 17 k = n; 18 while(k > 3) 19 { 20 for(j=0, i=1; i<=n; i++) 21 { 22 if(!b[i]) 23 { 24 j++; 25 if(j % 2 == 0) 26 { 27 b[i] = 1; 28 k--; 29 } 30 } 31 } 32 if(k <= 3) 33 break; 34 for(j=0, i=1; i<=n; i++) 35 { 36 if(!b[i]) 37 { 38 j++; 39 if(j % 3 == 0) 40 { 41 b[i] = 1; 42 k--; 43 } 44 } 45 } 46 } 47 printf("%d", a[1]); 48 for(i=2; i<=n; i++) 49 { 50 if(!b[i]) 51 printf(" %d",a[i]); 52 } 53 printf("\n"); 54 } 55 return 0; 56 }
//简单的思路, 我要体会学习的奥妙。~
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4696899.html