fzu 2037 Maximum Value Problem
2015-03-30 11:11
288 查看
http://acm.fzu.edu.cn/problem.php?pid=2037
思路:找规律,找出递推公式f
=f[n-1]*n+(n-1)!,另一个的结果也是一个递推,s
=s[n-1]+1/n;
View Code
思路:找规律,找出递推公式f
=f[n-1]*n+(n-1)!,另一个的结果也是一个递推,s
=s[n-1]+1/n;
#include <cstdio> #include <cstring> #include <algorithm> #define maxn 1000010 #define ll long long using namespace std; const int mod=1000000007; ll f[maxn]; int t; ll n; ll h[maxn]; double ans[maxn]; void inti() { h[0]=1; h[1]=1; ans[1]=1.0; for(int i=2; i<=maxn; i++) { ans[i]=ans[i-1]+1.0/i; h[i]=h[i-1]*i; h[i]%=mod; } f[1]=1; for(int i=2; i<=maxn; i++) { f[i]=(f[i-1]*i+h[i-1])%mod; } } int main() { inti(); scanf("%d",&t); for(int cas=1; cas<=t; cas++) { scanf("%lld",&n); printf("Case %d: %I64d %.6lf\n",cas,f ,ans ); } return 0; }
View Code
相关文章推荐
- fzu 2037 Maximum Value Problem(规律? 递推)
- FZU 2037- Maximum Value Problem(规律题)
- FZU 2037 Maximum Value Problem
- Maximum Value Problem FZU 2037 找规律 递推
- FZU 2037 Maximum Value Problem (打表预处理/找规律)
- Maximum Value Problem FZU - 2037
- fzu 2037 Maximum Value Problem(递推)
- FZU2037 Maximum Value Problem 规律 + 递推
- FZU 2037 Maximum Value Problem【递推】
- Solve the problem "Value was invalid" in .Net ICryptoTransform
- FZU1753 Another Easy Problem【组合数】
- FZU_Problem 2167 大王叫我来巡山呐
- fzu Problem 2129 子序列个数
- Maximum path sum I [Project Euler.Problem 18]
- 【FZU】Problem 2056 最大正方形
- fzu online judge Problem 1478 环形整数串
- FZU Problem 2132 LQX的作业 (数学题)
- http://acm.fzu.edu.cn/problem.php?pid=1698 最大乘积
- FZU Problem 2232 炉石传说(匈牙利算法)
- FZU Problem 2221 RunningMan(思维考查)——第六届福建省大学生程序设计竞赛-重现赛