SCU oj 4424 Permutations(递推)
来源:互联网 发布:韩国衣服品牌 淘宝 编辑:程序博客网 时间:2024/05/02 14:52
题目链接
4424: Permutations
Submit your solution Discuss this problem Best solutionsDescription
Given N distinct elements, how many permutations we can get from all the possible subset of the elements?Input
The first line is an integer T that stands for the number of test cases.Then T line follow and each line is a test case consisted of an integer N.Constraints:T is in the range of [0, 10000]N is in the range of [0, 8000000]Output
For each case output the answer modulo 1000000007 in a single line.Sample Input
501234Sample Output
0141564Author
baihacker
题解容易得出递推公式:f ( n ) = ( 1 + f( n-1 ) ) * n ;
代码如下:
#include<cstdio>#include<cstring>#include<set>#include<iostream>#include<map>#include<cmath>#include<string>#include<vector>#include<queue>#include<cctype>#include<algorithm>#define inff 0x3fffffff#define nn 8100000#define mod 1000000007typedef long long LL;using namespace std;LL ans[nn];int main(){ int i; ans[0]=0; for(i=1;i<=8000000;i++) { ans[i]=((ans[i-1]+1)*i)%mod; } int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%lld\n",ans[n]); } return 0;}
0 0
- SCU oj 4424 Permutations(递推)
- SCU 1118-上车人数(递推)
- scu oj 4443
- scu oj 4437: Carries
- UVA 11077 - Find the Permutations(递推)
- 华为OJ(递推公式)
- light OJ 1004(简单递推)
- scu oj 4441 Necklace(dp+树状数组)(*)
- LeetCode OJ算法题(四十五):Permutations
- LeetCode OJ 之 Permutations (排列)
- UVA 11077 Find the Permutations 置换+递推
- uva 11077 Find the Permutations 置换+递推
- 九度OJ 1081:递推数列 (递归,二分法)
- 【杭电oj】2050 - 折线分割平面(递推)
- 【杭电oj】5620 - KK's Steel(递推)
- 哈理工OJ 1124 Final Destination(简单递推)
- 【杭电oj】2044 - 一只小蜜蜂...(递推)
- Hust oj 1074 Hexagonal Tiles(递推)
- hdu2147kiki's game 博弈
- Exception in thread "main" java.net.ProtocolException: Invalid HTTP method: get
- 107Binary Tree Level Order Traversal II
- 常见的IO模型
- hdu 1176 免费馅饼(nyist 613)
- SCU oj 4424 Permutations(递推)
- Android中Intent传递对象的两种方法:Serializable & Parcelable
- POJ 1474 Video Surveillance 半平面交求多边形是否有核
- Maven最佳实践:版本管理
- 链表的创建、逆序显示、插入显示
- 编程之美2:寻找最大的K个数
- P51第17题
- 0-1分数规划(nyoj914 Yougth的最大化)
- 【每日一发】基于JS的图片瀑布流