一道让我纠结的水题——上海邀请赛The first place of 2^n
来源:互联网 发布:msp432用什么编程 编辑:程序博客网 时间:2024/05/21 18:50
The first place of 2^n p
Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u
[Submit] [Go Back] [Status]
Description
LMY and YY are mathematics and number theory lovers. They like to find and solve interesting mathematic problems together. One day LMY calculates 2n one by one, n=0, 1, 2,… and writes the results on a sheet of paper: 1,2,4,8,16,32,64,128,256,512,1024,……
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.
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.
Input
Input consists of one or more lines, each line describing one test case: an integer N, where 0≤N≤10000.
End of input is indicated by a line consisting of -1.
End of input is indicated by a line consisting of -1.
Output
For each test case, output a single line. Each line contains nine integers. The ith integer represents the number of js satisfying the condition that 2jbegins with i (0≤j≤N).
Sample Input
01310-1
Sample Output
1 0 0 0 0 0 0 0 01 1 0 0 0 0 0 0 01 1 0 1 0 0 0 1 04 2 1 1 1 1 0 1 0
[Submit] [Go Back] [Status]
我一开始以为有规律可循,没想到后面的根本不符合,一时大意铸成大错!
#include<iostream>#include<cstdio>#include<cstring>using namespace std;const int Max = 10005;int map[Max][10];int main(){ int i, j, num; double w = 1;//唉使用double类型进行处理。。巧妙啊(换成__int64就会WA,我要死了) map[0][1] = 1; for(i = 1; i <= 10002; i ++){ for(j=1;j<=9;j++){ map[i][j] = map[i-1][j]; } w*= 2; if(w > 10) w /= 10; map[i][(int)(w)] ++; } while(cin>>num){ if(num==-1) break; cout<<map[num][1]; for(i=2;i<=9;i ++){ cout<<" "<<map[num][i]; } cout<<endl; } return 0;}
- 一道让我纠结的水题——上海邀请赛The first place of 2^n
- HDU/HDOJ 3215 The first place of 2^n
- Hdu 3215 The first place of 2^n (对数)
- HDU 3215 The first place of 2^n (数论-水题)
- HDU 3215 The first place of 2^n(数论-其他)
- hdoj The first place of 2^n 3215 (数学技巧&预处理)
- HDU 3215 The first place of 2^n(计算2^0到2^n首位出现的1,2,3...9的个数)
- 一道让我纠结了几天的面试题
- HDU 5095 Linearization of the kernel functions in SVM (上海邀请赛水题)
- 让人纠结的N皇后问题
- HDU 5099 Comparison of Android versions(上海邀请赛模拟水题)
- 2011ACM上海邀请赛D题(Detection of Extraterrestrial)----KMP
- 2015上海邀请赛——Game
- 让我很纠结的一个问题
- 让我纠结的各种“网”
- The Coldest Place On Earth——Chapter 9 The End of the Race
- POJ 3100 Root of the Problem(我的水题之路——取A^N最接近B的A)
- POJ 2209 The King(我的水题之路——n次方之和)
- corba stub 作用
- 安装和使用花生壳(linux)
- DOS命令大全
- 软件缺陷的严重性和优先级
- 非阻塞 多线程、网络编程等
- 一道让我纠结的水题——上海邀请赛The first place of 2^n
- 表的自身查询问题
- 关于矩阵的一些理解
- 预处理指令pragma常见用法集锦(#pragma once、#pragma comment和#pragma warning)
- 百度高级科学家——王海峰
- 测试人员容易遗漏一些隐藏的缺陷
- Android,谁动了我的内存(转)
- android动画类型
- c位域