HDU 3215 The first place of 2^n (数论-水题)
The first place of 2^n
LMY discovers that for every consecutive 3 or 4 results, there must be one among them whose first digit is 1, and comes to the conclusion that the first digit of 2n isn’t evenly distributed between 1 and 9, and the number of 1s exceeds those of others. YY now
intends to use statistics to prove LMY’s discovery.
End of input is indicated by a line consisting of -1.
0
1
3
10
-1
1 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0
1 1 0 1 0 0 0 1 0
4 2 1 1 1 1 0 1 0
题目大意“:
妈呀,这是我们大东华09年出的题啊,好厉害,事实上是好水啊。
题目大意就是计算2^0到2^n这n个数首位为1的次数,2的次数,...9的次数。
解题思路:
我是不会告诉你log10一下就会找到你想要的东西的。
解题代码:
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std; const int maxn=10010;
const double lg2=log10(2.0);
int a[maxn]; void ini(){
a[0]=1,a[1]=2,a[2]=4,a[3]=8;
for(int i=4;i<maxn;i++){
double x=i*lg2-int(i*lg2+1e-7);
a[i]=pow(10.0,x);
}
//for(int i=0;i<20;i++) cout<<"2^"<<i<<" :"<<a[i]<<endl;
} int main(){
ini();
int n;
while(scanf("%d",&n)!=EOF && n!=-1){
int cnt[10]={0};
for(int i=0;i<=n;i++){
cnt[a[i]]++;
}
printf("%d",cnt[1]);
for(int i=2;i<=9;i++){
printf(" %d",cnt[i]);
}
printf("\n");
}
return 0;
}
HDU 3215 The first place of 2^n (数论-水题)的更多相关文章
- hdu 3687 10 杭州 现场 H - National Day Parade 水题 难度:0
H - National Day Parade Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & % ...
- HDU 1576 A/B 数论水题
http://acm.hdu.edu.cn/showproblem.php?pid=1576 写了个ex_gcd的模板...太蠢导致推了很久的公式 这里推导一下: 因为 1 = BX + 9973Y ...
- HDU - 4788 Hard Disk Drive (成都邀请赛H 水题)
HDU - 4788 Hard Disk Drive Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I ...
- hdu 4524 郑厂长系列故事——逃离迷宫 小水题
郑厂长系列故事——逃离迷宫 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) To ...
- hdu 5038 (2014北京网络赛G 排序水题)
题意:有n个数字,带入10000 - (100 - ai) ^ 2公式得到n个数,输出n个数中频率最大的数,如果有并列就按值从小到大都输出输出,如果频率相同的数字是全部的n个数,就输出Bad....题 ...
- hdu 2553:N皇后问题(DFS遍历,水题)
N皇后问题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- HDU 4662 MU Puzzle (2013多校6 1008 水题)
MU Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- HDU 4639 Hehe (2013多校4 1008 水题)
Hehe Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- HDU 6322.Problem D. Euler Function -欧拉函数水题(假的数论题 ̄▽ ̄) (2018 Multi-University Training Contest 3 1004)
6322.Problem D. Euler Function 题意就是找欧拉函数为合数的第n个数是什么. 欧拉函数从1到50打个表,发现规律,然后勇敢的水一下就过了. 官方题解: 代码: //1004 ...
随机推荐
- Android底层开发之Linux输入子系统要不要推断系统休眠状态上报键值
Android底层开发之Linux输入子系统要不要推断系统休眠状态上报键值 题外话:一个问题研究到最后,那边记录文档的前半部分基本上都是没用的,甚至是错误的. 重点在最后,前边不过一些假想猜測. ht ...
- SpringMVC整合Shiro,Shiro是一个强大易用的Java安全框架,提供了认证、授权、加密和会话管理等功能
SpringMVC整合Shiro,Shiro是一个强大易用的Java安全框架,提供了认证.授权.加密和会话管理等功能. 第一步:配置web.xml <!-- 配置Shiro过滤器,先让Shiro ...
- poj 3071 Football(线段树+概率)
Football Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2801 Accepted: 1428 Descript ...
- 4、qq物联SDK介绍及实例讲解
1.到QQ物联官网http://iot.open.qq.com中下载软件SDK S3C2440_20161122_1.6.205_r4288.tar.gz注意:在后续大家实际开发过程中,可能你会下载到 ...
- Caffe 学习:Crop 层
在Fully Convolutional Networks(FCN)中,会用到Crop 层,他的主要作用是进行裁切.下面我们举一个例子来说明如何使用Crop 层. Caffe中的数据是以 blobs形 ...
- 《SPA设计与架构》之客户端路由
原文 简书原文:https://www.jianshu.com/p/4d83475f71da 大纲 1.传统路由 2.SPA导航 3.客户端路由器的工作机制 1.传统路由 在传统Web应用程序中,导航 ...
- ng-cli搭建angular项目框架
原文地址 https://www.jianshu.com/p/0a8f4b0f29b3 环境准备 以下步骤都不需要事先创建文件夹,只是环境的准备过程,只有到需要搭建项目的时候才需要创建文件夹用来存放项 ...
- 【23.39%】【codeforces 558C】Amr and Chemistry
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【38.02%】【codeforces 625B】War of the Corporations
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 一起talk C栗子吧(第八十三回:C语言实例--进程间通信概述)
各位看官们,大家好,前二回中咱们说的是进程停止的样例,这一回咱们说的样例是:进程间通信.闲话休提,言归正转.让我们一起talk C栗子吧! 看官们.每一个进程都拥有自己的资源,假设不同进程之间须要共享 ...