hdu 1042】的更多相关文章

HDU 1042 N! 题意:给定整数N(0 ≤ N ≤ 10000), 求 N! (题目链接) #include <iostream> using namespace std; //每一个数组元素存放5位数 const int MAX=100000; //%MAX后结果为[0,99999] const int N=10001; //7132+1 int a[N]={0}; void prtBig(int n) { for(int i=0; i<n;i++) { if(i==0) //最…
B - 2 Time Limit:5000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1042 Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!  Input One N in one line, process to the end of file.  Out…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1042 N! Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in one line, process to the end of file. Output For each N, output N! in one line. Sample Input 123 Sample…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题目大意:求n!, n 的上限是10000. 解题思路:高精度乘法 , 因为数据量比较大, 所以得用到缩进,但因为是乘法,缩进只能在10^5, 不然在乘的过程中就超过int型.然后数值位数大概在8000位以下. #include <iostream> #include <string.h> using namespace std; const int MAXN = 100000;…
N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 60244    Accepted Submission(s): 17166 Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in on…
Problem Description Givenan integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input OneN in one line, process to the end of file. Output Foreach N, output N! in one line. Sample Input 1 2 3 Sample Output 1 2 6 Author JGShining(极光炫影) /********* 高…
N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 34687    Accepted Submission(s): 9711 Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in one…
N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 55659    Accepted Submission(s): 15822 Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in on…
貌似之前也写过这个题目的解题报告...老了,记性不好 从贴一遍吧! 代码理解很容易 AC代码: #include <iostream> #include <stdio.h> #include <cstring> using namespace std; #define N 8000 int main() { int i,j,k,t,n; int a[N]; while(cin>>n) { memset(a,0,sizeof(a)); a[0]=1; for(…
Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in one line, process to the end of file.   Output For each N, output N! in one line.   Sample Input 1 2 3   Sample Output 1 2 6 一看到题目就想到用高精度乘法,用数组模拟小学学过…
使用java还不熟练,错误在于读入.应用in.hasNext() 代码 import java.text.ParseException; import java.text.SimpleDateFormat; import java.math.BigInteger; import java.util.Date; import java.util.Scanner; public class Main { public static void main(String[] args) throws Pa…
N!                                                                              Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!  …
Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in one line, process to the end of file.   Output For each N, output N! in one line.   题目大意:求N的阶乘. 思路:用高精度,内存存不下这么多只能每次都重新算了…… 代码(3093MS): //模板测试 #inclu…
N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 73503    Accepted Submission(s): 21308 Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in…
题意:求n!(0 ≤ N ≤ 10000) 思路:大数,用数组存储 1.首先要考虑数据N!的位数,因为最大是10000!,可以计算一下大概是5+9000*4+900*3+90*2+10*1=38865位,(此处没看懂,怎么求的) 可以开一个40000的int数组存放,然后用常规的方法去计算 2.但是需要改进一下,咱们知道int数组一个只存1位太浪费了,不如让它的空间发挥到极限,数组一个元素存一个不超过10^5的数, 为什么是10^5呢?见代码中的注释,改进后就一个元素存5位,这样开的数组就可以小…
这道题一开始就采用将一万个解的表打好的话,虽然时间效率比较高,但是内存占用太大,就MLE 这里写好大数后,每次输入一个n,然后再老老实实一个个求阶层就好 java代码: /** * @(#)Main.java * * * @author * @version 1.00 2014/12/21 */ import java.util.*; import java.math.*; public class Main { //public static BigInteger a [] = new Big…
N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 65350    Accepted Submission(s): 18696 Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in…
N! Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in one line, process to the end of file.   Output For each N, output N! in one line.   Sample Input 1 2 3   Sample Output 1 2 6 高精度乘法.数组存,每一位存5位数,不然会…
链接:传送门 思路:高精度乘法板子题,高精度耗时又耗空间...... /************************************************************************* > File Name: hdu1042.cpp > Author: WArobot > Blog: http://www.cnblogs.com/WArobot/ > Created Time: 2017年05月16日 星期二 21时07分58秒 ********…
N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 100274    Accepted Submission(s): 30006 Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in…
HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsum  贪心 HDU 1004 Let the Balloon Rise  字典树,map HDU 1005 Number Sequence  求数列循环节 HDU 1007 Quoit Design  最近点对 HDU 1008 Elevator  模拟 HDU 1010 Tempter of th…
Java--大数计算,妈妈再也不用担心我的学习了 . BigInteger 英文API: http://docs.oracle.com/javase/8/docs/api/ 中文API: http://tool.oschina.net/apidocs/apidoc?api=jdk-zh import java.math.BigInteger; import java.util.Scanner; //hdu 1002----A + B Problem II public class Main {…
8-15-小练 这次的题目......只觉得泪奔啊......T T A.HDU 1042   N! 因为0<=n<=1000,故一定要用数组或字符串[同样因为n<=1000故用数组就够了~~~]. 代码: #include <iostream> #include <cstdio> using namespace std; ]; int main() { int n,i,j; while(~scanf("%d",&n)) { || n=…
HDU1042(N!)题解 以防万一,题目原文和链接均附在文末.那么先是题目分析: [一句话题意] 计算N的阶乘并输出. [题目分析] 题给范围上限是10000,那么毫无疑问是大数题.之前我整理过各种大数的代码并且改了改然后所谓封装了一下,于是这道题就直接用了个类似的代码修改了一下,然后...交上去就对了(喂..).但是作为题解,怎么着也得把做法解释清楚吧.. 以下为c语言代码(虽然是cpp提交的,也带了一堆cpp头文件),也附带了代码解释.代码很好懂,看看解释应该看得明白.还有...如果你是写…
poj 1001 Exponentiation import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNextBigDecimal()) { BigDecimal a = in.nextBigDecimal(); int b = in.nextInt()…
以下是三种高精度算术的模版: 高精度加法: ",s1,s2; ],ss2[],len; void dashu(string s1,int ss1[]) { ;i>=;i--) { ;j<;j++) { if(s[j]==s1[i]) ss1[s1.length()--i]=j; } } } void dashu_add(int ss1[],int ss2[]) { int len1=s1.length(),len2=s2.length(); if(len1>len2) len=…
打2017icpc沈阳站的时候遇到了大数的运算,发现java与c++比起来真的很赖皮,竟然还有大数运算的函数,为了以后打比赛更快的写出大数的算法并且保证不错,特意在此写一篇博客, 记录java的大数运算,也算是ACM java写法的入门: 学习博客:https://www.cnblogs.com/wkfvawl/p/9377441.html 进入到eclipse界面 第一步:file->new->java project->起名->finish 第二步:进入到刚才建的工程里,右键s…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1042 Problem Description Given an integer N( ≤ N ≤ ), your task is to calculate N! Input One N in one line, process to the end of file. Output For each N, output N! in one line. Sample Input Sample…
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1042 Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in one line, process to the end of file.   Output For each N, output N! in one line.   Sample Input…