首页 > 代码库 > HDU - 6033 Add More Zero
HDU - 6033 Add More Zero
题意:已知m,求使10k不超过2m-1的最大的k。
分析:
1、2m都是以2,4,6,8结尾,因此减1不影响2m-1的位数。
2、令10k=2m,则k=m * log102,下取整即可。
#include<cstdio>#include<cstring>#include<cstdlib>#include<cctype>#include<cmath>#include<iostream>#include<sstream>#include<iterator>#include<algorithm>#include<string>#include<vector>#include<set>#include<map>#include<stack>#include<deque>#include<queue>#include<list>#define lowbit(x) (x & (-x))const double eps = 1e-8;inline int dcmp(double a, double b){ if(fabs(a - b) < eps) return 0; return a > b ? 1 : -1;}typedef long long LL;typedef unsigned long long ULL;const int INT_INF = 0x3f3f3f3f;const int INT_M_INF = 0x7f7f7f7f;const LL LL_INF = 0x3f3f3f3f3f3f3f3f;const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};const int MOD = 1e9 + 7;const double pi = acos(-1.0);const int MAXN = 10000 + 10;const int MAXT = 10000 + 10;using namespace std;int main(){ int m; int kase = 0; while(scanf("%d", &m) == 1){ printf("Case #%d: %d\n", ++kase, (int)(m * log10(2.0))); } return 0;}
HDU - 6033 Add More Zero
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。