hdu 1018 Big Number (数学题)】的更多相关文章

Problem Description Inmany applications very large integers numbers are required. Some of theseapplications are using keys for secure transmission of data, encryption, etc.In this problem you are given a number, you have to determine the number ofdig…
LINK:HDU 1018 题意:求n!的位数~ 由于n!最后得到的数是十进制,故对于一个十进制数,求其位数可以对该数取其10的对数,最后再加1~ 易知:n!=n*(n-1)*(n-2)*......*3*2*1 ∴lg(n!)=lg(n)+lg(n-1)+lg(n-2)+......+lg(3)+lg(2)+lg(1); 代码: #include <iostream> #include <cstdio> #include <cmath> using namespace…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 解题报告:输入一个n,求n!有多少位. 首先任意一个数 x 的位数 = (int)log10(x) + 1; 所以n!的位数 = (int)log10(1*2*3*.......n) + 1; = (int)(log10(1) + log10(2) + log10(3) + ........ log10(n)) + 1; #include<cstdio> #include<cstrin…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 21106    Accepted Submission(s): 9498 Problem Description In many applications very large integers numbers are required. Some of these…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 34084    Accepted Submission(s): 16111 Problem Description In many applications very large integers numbers are required. Some of these…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 40262    Accepted Submission(s): 19637 Problem Description In many applications very large integers numbers are required. Some of these…
Problem Description In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of…
Problem Description In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of…
Big Number 题意:算n!的位数. 题解:对于一个数来算位数我们一般都是用while去进行计算,但是n!这个数太大了,我们做不到先算出来在去用while算位数. while(a){ cnt++; a/=; } 将一个数对取10对数(取整),然后再加一就是这个数的位数,然后我们在算n!的时候每次对10取对数就好了. #include<iostream> #include<cmath> using namespace std; int main() { ios::sync_wi…
题意: 给一个数n,返回该数的阶乘结果是一个多少位(十进制位)的整数. 思路: 用对数log来实现. 举个例子 一个三位数n 满足102 <= n < 103: 那么它的位数w 满足 w = lg103 = 3. 因此只要求lgn 向下取整 +1就是位数.然后因为阶乘比如5阶乘的话是5 * 4 * 3 * 2 * 1.位数就满足lg 5 * 4 * 3 * 2 * 1 = lg5 + lg4 + lg3 + lg2 + lg1.用加法就不会超过数字上限. 当然这是十进制下得.如果是m进制下 ,…
1. 利用数学公式lg(n!)=lg(2)+lg(3)+....+lg(n) 求解 2.…
传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 pre:上一位的奇偶性 status:截止到上一位的连续段的奇偶性 ze:是否有前导0 /************************************************************** Problem:hdu 5898 odd-even number User: yo…
划分树 /* HDU 2665 Kth number 划分树 */ #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; ; ][MAXN];//表示每层每个位置的值 int sorted[MAXN];//已经排序的数 ][MAXN];//toleft[p][i]表示第i层从1到i有多少个数分入左边 void build…
Cube number on a tree Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1628    Accepted Submission(s): 382 Problem Description The country Tom living in is famous for traveling. Every year, man…
在今天三黑(恶意评分刷上去的那种)两紫的智推中,突然出现了P3834 [模板]可持久化线段树 1(主席树)就突然有了不详的预感2333 果然...然后我gg了!被大佬虐了! hdu 2665 Kth number 题意就不写了,太经典了(可我还是不会这题,我太菜了) 大佬的题解写的太神仙了,我这么菜的人都看懂了2333,所以我就不写了... 不过这题是真的坑啊...老师在上面讲的时候,我们开始提交(他们交主席树,我交整体二分)然后等讲完我们还没过23333 MLE.TLE.WA(可能还有CE)轮…
HDU - 1711 A - Number Sequence   Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K + 1] = b[2], ...... ,…
大意就是求 : log10(n!) = log10(1 * 2 *  3 * .......*n) = log10(1) + log10(2) + ........+log10(n); 打表的话会MLE,直接递推即可了.后台数据不会非常刁钻. #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long…
Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18543    Accepted Submission(s): 11246 Problem Description The inversion number of a given number sequence a1, a2, ..., a…
K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 50247   Accepted: 17101 Case Time Limit: 2000MS Description You are working for Macrohard company in data structures department. After failing your previous task about key inse…
Balanced Number Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 3798    Accepted Submission(s): 1772 Problem Description A balanced number is a non-negative integer that can be balanced if a pi…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5166 Missing number Description There is a permutation without two numbers in it, and now you know what numbers the permutation has. Please find the two numbers it lose. Input There is a number T shows t…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Big Number Description As we know, Big Number is always troublesome. But it's really important in our ACM. And today, your task is to write a program to calculate A mod B. To make the problem easier…
K-wolf Number 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5787 Description Alice thinks an integer x is a K-wolf number, if every K adjacent digits in decimal representation of x is pairwised different. Given (L,R,K), please count how many K-wolf…
http://acm.hdu.edu.cn/showproblem.php?pid=2665 [ poj 2104 2761 ]  改变一下输入就可以过 http://poj.org/problem?id=2104 http://poj.org/problem?id=2761 Kth number Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submissio…
Kth number Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 37 Accepted Submission(s): 25   Problem Description Give you a sequence and ask you the kth big number of a inteval.   Input The first l…
Big Number 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1212 ——每天在线,欢迎留言谈论. 题目大意: 给你两个数 n1,n2.其中n1 很大很大,n1%n2的值. 知识点: ①秦九韶公式:例:1314= ((1*10+3)*10+1)*10+4 ②(a*b)%c == (a%c)*(b%c) .(a+b)%c == (a%c)+(b%c) . 思路: 每步取模即可. C++ AC代码: #include <iostream> #…
题目:odd-even number 链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5898 题意:给一个条件,问l 到r 之间有多少满足条件的数,条件是:连续的奇数长度为偶数,连续的偶数长度为奇数,比如124683,连续的奇数(1.3)长度都是1(奇数),连续的偶数(2468)长度为4(偶数),所以不满足条件. 思路: 很明显的数位dp,可以用dfs做,传下三个参数(pre.p1.p2.ceng),pre表示前一位的数是奇数还是偶数,p1…
Kth number Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11394    Accepted Submission(s): 3465 Problem Description Give you a sequence and ask you the kth big number of a inteval.   Input The…
Poor Hanamichi Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 743    Accepted Submission(s): 275 Problem Description Hanamichi is taking part in a programming contest, and he is assigned to so…
Kth number Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Give you a sequence and ask you the kth big number of a inteval.   Input The first line is the number of the test cases. For each test…