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;
}

  

时间: 2024-08-10 11:38:45

HDU - 6033 Add More Zero的相关文章

HDU 6033 Add More Zero (数学)

题目链接:https://vjudge.net/problem/HDU-6033 这水题好难想...... 题意:给一个数m,求一个数k满足10^k小于等于2^m-1. 这题其实是简单的公式化简: = 10^k <= 2^m-1 = 10^k < 2^m = ln10^k < ln 2^m = k*ln10 < m*ln2 = k < m*1n2/1n10 代码: int main() { int cnt=0,m; while(cin>>m) { int ans=

HDU 2162 Add ‘em

http://acm.hdu.edu.cn/showproblem.php?pid=2162 Problem Description Write a program to determine the summation of several sets of integers. Input The input file will consist of up to 250 sets of integers, where each set contains at most 100 integers a

HDOJ(HDU) 2162 Add ‘em(求和)

Problem Description Write a program to determine the summation of several sets of integers. Input The input file will consist of up to 250 sets of integers, where each set contains at most 100 integers and the integer values will be between –16000 an

设置IIS,使其只能接收国内的用户访问(IP限制)

IP明细参考 先找到国内所有的IP http://ipblock.chacuo.net/view/c_CN 执行脚本 IIS白名单设置 powershell #国内IP白名单 Import-Module WebAdministration $webSite = 'TEST.WEBSITE' function Func { param ( $ipAddr, $ipMask ) # Add new IP CIDR entry to restrictions to website Test Add-W

HDU 5542 The Battle of Chibi dp+树状数组

题目:http://acm.hdu.edu.cn/showproblem.php?pid=5542 题意:给你n个数,求其中上升子序列长度为m的个数 可以考虑用dp[i][j]表示以a[i]结尾的长度为j的上升子序列有多少 裸的dp是o(n2m) 所以需要优化 我们可以发现dp的第3维是找比它小的数,那么就可以用树状数组来找 这样就可以降低复杂度 #include<iostream> #include<cstdio> #include<cstring> #include

HDU 5917 Instability ramsey定理

http://acm.hdu.edu.cn/showproblem.php?pid=5917 即世界上任意6个人中,总有3个人相互认识,或互相皆不认识. 所以子集 >= 6的一定是合法的. 然后总的子集数目是2^n,减去不合法的,暴力枚举即可. 选了1个肯定不合法,2个也是,3个的话C(n, 3)枚举判断,C(n, 4), C(n, 5) #include <bits/stdc++.h> #define IOS ios::sync_with_stdio(false) using name

hdu 1565 方格取数(2)(网络流之最大点权独立集)

题目链接:hdu 1565 方格取数(2) 题意: 有一个n*m的方格,每个方格有一个数,现在让你选一些数.使得和最大. 选的数不能有相邻的. 题解: 我们知道对于普通二分图来说,最大独立点集 + 最小点覆盖集 = 总点数,类似的,对于有权的二分图来说,有: 最大点权独立集 + 最小点权覆盖集 = 总点权和, 这个题很明显是要求 最大点权独立集 ,现在 总点权 已知,我们只要求出来 最小点权覆盖集 就好了,我们可以这样建图, 1,对矩阵中的点进行黑白着色(相邻的点颜色不同),从源点向黑色的点连一

hdu 4735 Little Wish~ lyrical step~(DLX)

题目链接:hdu 4735 Little Wish~ lyrical step~ 题意: 有n个节点的树,每个节点可能是男孩,可能是女孩,节点之间有距离,现在要让所有的女孩周围距离D之内有男孩,问最小需要交换多少次男孩和女孩的位置. 题解: 把每个节点对小于D距离的全部link起来,然后DLX爆艹,意义就是选n个节点去覆盖全部节点,如果这个节点是女生,那么就是要替换的点.然后不断更新答案. 1 #include<bits/stdc++.h> 2 #define F(i,a,b) for(int

HDU 3397 Sequence operation(线段树)

HDU 3397 Sequence operation 题目链接 题意:给定一个01序列,有5种操作 0 a b [a.b]区间置为0 1 a b [a,b]区间置为1 2 a b [a,b]区间0变成1,1变成0 3 a b 查询[a,b]区间1的个数 4 a b 查询[a,b]区间连续1最长的长度 思路:线段树线段合并.须要两个延迟标记一个置为01,一个翻转,然后因为4操作,须要记录左边最长0.1.右边最长0.1,区间最长0.1,然后区间合并去搞就可以 代码: #include <cstdi