HDU 2139 Calculate the formula】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=2139 Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2.   Input In each case, there is an odd positive integer n.   Output Print the sum. Make sure the sum will not e…
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 看到这个时间,我懵逼了... 果然,Java就是打表,都不能AC,因为Java的输入是流,需要的时间比C真的长好多.... Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+--+ n ^2. Input In each…
Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2.   Input In each case, there is an odd positive integer n.   Output Print the sum. Make sure the sum will not exceed 2^31-1   Sample Input 3   Sample Output 1…
http://acm.hdu.edu.cn/showproblem.php?pid=2114 Problem Description Calculate S(n). S(n)=13+23 +33 +......+n3 .   Input Each line will contain one integer N(1 < n < 1000000000). Process to end of file.   Output For each case, output the last four dig…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2114 自己对数论一窍不通啊现在,做了一道水题,贴出来吧...主要是让自己记住这个公式: 前n项和的立方公式为   : s(n)=(n*(n+1)/2)^2; 前n项和的平方公式为:s(n)=n*(n+1)(2*n+1)/6; 代码: #include<iostream> #include<cstdlib> #include<cstdio> using namespace s…
传送门 题意:从输入开始,1.输入样例数:2.然后输入一组样例中的行数n:3.前n-1行为定义变量(之间使用空格隔开),只需要map存进去就可以了(这里有覆盖的情况,故使用mp["s"] = "***"的方法赋值,因为insert的方法如果里面存在的话,插不进入数值):4.然后就是最后一行输入计算式子(之间使用空格隔开). 思路:我使用的字符流的方法分割的的字符串,因为题中说了使用空格隔开的: 变量的储存使用map就可以,在最后一行输入计算式子之后,同样使用字符流分…
题意 已知公式:$\pi=\sum_{k=0}^{\infty}\left[\frac{1}{16^{k}}\left(\frac{4}{8 k+1}-\frac{2}{8 k+4}-\frac{1}{8 k+5}-\frac{1}{8 k+6}\right)\right]$ 求 $\pi$ 的第 $n$ 项. 分析 WIKI上有:π的BBP位抽取算法 这类公式是用来求解一些无理数常数的公式,特点是不需要求解前n-1位也能去算第n位 将公式乘以 $16^n$ 就能将小数点移动到第 $n$ 位.…
Fibonacci Check-up Problem Description Every ALPC has his own alpc-number just like alpc12, alpc55, alpc62 etc.As more and more fresh man join us. How to number them? And how to avoid their alpc-number conflicted? Of course, we can number them one by…
History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 434264-bit integer IO format: %I64d      Java class name: Main Prev Submit Status Statistics Discuss Next Type: None   None Graph Theory 2…
C - History repeat itself Time Limit:1000MS     Memory Limit:32768KB      Description Tom took the Discrete Mathematics course in the 2011,but his bad attendance angered Professor Lee who is in charge of the course. Therefore, Professor Lee decided t…
History repeat itself Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4342 Description Tom took the Discrete Mathematics course in the 2011,but his bad attendance angered Professor Lee who is in…
建议入门的人先看cd琦的<基于连通性状态压缩的动态规划问题>.事半功倍. 插头DP其实是比较久以前听说的一个东西,当初是水了几道水题,最近打算温习一下,顺便看下能否入门之类. 插头DP建议先理解“插头”的概念.然后会HASH表(这个其实是很基础的东西,应该都会的).然后就是DP. 以及特殊题目的特殊处理. 好像一般是求N,M<=12的网格图的某种回路数或某种通路数的方案数. 大体上每个题说几句特殊处理,有问题请纠正....题目的顺序基本上难度递增 另外代码我都是用括号匹配的.因为感觉连通…
Fibonacci Check-up Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 42 Accepted Submission(s): 27   Problem Description Every ALPC has his own alpc-number just like alpc12, alpc55, alpc62 etc.As mo…
原文网址:http://bbs.elecfans.com/jishu_354666_1_1.html 再过1个月又是一年应届毕业生应聘的高峰期了,为了方便应届毕业生应聘,笔者将大学四年C语言知识及去年本人C语言笔试难点进行梳理,希望能对今年应届毕业生的应聘有所帮助. 2013年10月18日更新-->    攻破C语言这个帖子更新到这里,我不仅仅是为了补充大学学生遗漏的知识,我更重要的是希望通过我的经验,你们实际项目中的C语言写得漂亮,写出属于你的风格.“朱兆祺STM32手记”(http://bb…
This is an interesting question from one of the lab assignments in Introduction to Computer Systems, fall 2018 at Peking University. Problem Description Given a 32-bit integer \(x\)(in two's complement), implement a C function that returns \(\frac{x}…
本文链接:https://blog.csdn.net/qq_43467898/article/details/83187698Django微信小程序后台开发教程1 申请小程序,创建hello world小程序2 添加交互框和按钮3 在服务器配置hello django4 实现计算器接口5 配置服务器将后端与微信小程序连接5.1 uwsgi配置5.2 http协议(80端口)下的nginx配置5.3 https协议(443端口)下的nginx配置5.4 配置微信小程序的服务器信息1 申请小程序,创…
u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 46844    Accepted Submission(s): 21489 Problem Description A simple mathematical formula for e is where n is allowed to go to infini…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1012 u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 52607    Accepted Submission(s): 24106 Problem Description A simple mathematical…
u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28686    Accepted Submission(s): 12762 Problem Description A simple mathematical formula for e is where n is allowed to go to infini…
u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 35137 Accepted Submission(s): 15824 Problem Description A simple mathematical formula for e is where n is allowed to go to infinity. T…
http://acm.hdu.edu.cn/showproblem.php?pid=5139 思路:这道题要先找规律,f(n)=n!*(n-1)!*(n-2)!.....1!;  不能直接打表,而是离线处理,一次性处理出来. #include <cstdio> #include <cstring> #include <map> #include <algorithm> #define ll long long #define mod 1000000007 #…
Problem Description A simple mathematical formula for e is where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.   Output Output the approximations of e generated by the ab…
题目链接: HDU 7217 题意: 题目给你可以计算 \(π\) 的公式: \(\pi = \sum_{k=0}^{\infty}[\frac{1}{16^k}(\frac{4}{8k+1})-(\frac{2}{8k+4})-(\frac{1}{8k+5})-(\frac{1}{8k+6})]\) 告诉你可以求十六进制下的小数点后 \(π\) 的第 \(n\) 位,而不用计算前 \(n-1\) 项. 十六进制表示下,问你 \(π\) 的小数点后的第 \(n\) 位是多少 $ (1 ≤ n ≤…
题意就不说了,求公式. 解法: 稍加推导能够得出 : f(n) = n! * f(n-1) , 即其实是求: ∏(n!)  ,盲目地存下来是不行的,这时候看见条件: 数据组数 <= 100000, 那么我们可以离线做,先把他们存下来,然后再从小到大扫一边, 也就是最多10000000次乘法的复杂度.然后离线输出即可. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <…
插头DP基础题的样子...输入N,M<=11,以及N*M的01矩阵,0(1)表示有(无)障碍物.输出哈密顿回路(可以多回路)方案数... 看了个ppt,画了下图...感觉还是挺有效的... 参考http://www.cnblogs.com/kuangbin/archive/2012/10/02/2710343.html 以及推荐cd琦的论文ppthttp://wenku.baidu.com/view/4fe4ac659b6648d7c1c74633.html 向中学生学习~~ 感觉以后可能还会要…
题目就是求这个 n达到10^7,测试数据组数为10^5 为了防止TLE,一开始把每个n对应的值先求出来,但发现竟然开不了10^7的数组(MLE),然后就意识到这是第一道卡内存的题目... 只能离线做,把每个n从小到大排序,然后从小到大依次求,然后把结果存下来,最后排回去输出. #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm&…
题解:直接模拟 #include <cstdio> int main(){ puts("n e");puts("- -----------");puts("0 1"); double ans=1.0,f=1.0; for(int i=1;i<=9;i++){ if(i==1)printf("%d %.0lf\n",i,(ans+=(f/=(double)i))); else if(i==2)printf(&q…
题解 代码 #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1LL<<30; const int N = 10000000; int prime[N+5], low[N+5], check[N+5], pow_cnt[N+5], tot, f[N+5], f2[N+5], f3[N+5]; void sieve() { memset(check, 0, sizeof…
这是一道简单的数学计算问题   主义好输出格式就好 #include<stdio.h> int main() { printf("n e\n- -----------\n"); int a[10]; a[0]=1; for(int i=1;i<10;i++)  a[i]=a[i-1]*i; double e[10]; e[0]=1; for(int i=1;i<10;i++) { e[i]=e[i-1]+(double)1/a[i]; } for(int i=0…
分析:注意格式. #include<stdio.h> int main() { int i,j,k; double sum=0; printf("n e\n- -----------\n"); printf("0 1\n1 2\n2 2.5\n"); for(i=3;i<=9;i++) { k=1; for(j=1;j<=i;j++) k*=j; sum+=1.0/k; printf("%d %.9lf\n",i,sum+…