Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
太水了#include <iostream> #include <stdio.h> #include <vector> using namespace std; vector<int> r; void c(int n){ if(!n) return; int k = 2; for(; (1<<k)-1<=n; k++); if(n==(1<<k)-2){ for(int i = 0; i < 2; i++) r.push_back(k-2); return; } r.push_back(k-2); c(n-(1<<(k-1))+1); } int main() { int t; scanf("%d", &t); for(int I = 0; I < t; I++){ r.clear(); int n; scanf("%d", &n); printf("%d [", n); c(n); int z = r.size(); for(int i = z-1; i >= 0; i--){ printf("%d", r[i]); if(i) printf(","); } printf("]\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator