标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 500 Accepted Submission(s): 189
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <math.h> #include <iostream> #include <string> #include <algorithm> #define PI acos(-1.0) #define INF 1e9 using namespace std; int dd[100]; int main() { int t; scanf("%d", &t); int n; memset(dd, 0, sizeof(dd)); int ans; int e=1; dd[e++]=1; ans=1; int i=1; while(ans < INF ) { ans=ans+pow(2, i); i++; dd[e++]=ans; } // printf("-----%d\n", i); int cnt=1; while(t--) { scanf("%d", &n); int pos; for(i=0; i<e; i++) { if(n>=dd[i] && n<dd[i+1]) { pos=i; break; } } printf("Case #%d: %d\n", cnt++, pos ); } return 0; }
hdu 2015校赛1002 Dual horsetail (思维题 )
标签:
原文地址:http://www.cnblogs.com/yspworld/p/4377036.html