csu 1525: Algebraic Teamwork
来源:互联网 发布:java获取访问者ip 编辑:程序博客网 时间:2024/05/29 03:56
1.permutation应该翻译成置换
2.
idempotent function:集合A中的每个元素的对应自己本身的映射
3.集合A有n个元素,那么non-idemponent permutations of a set A的个数为n!-1
4.ans=(n!-1)%(1e9+7)
5.在Visual C++中int型的范围-2147483648~2147483647,简单记忆为-2e9~2e9
6.a*b%c=(a%c*b%c)%c
7.f[n]=n!%c
f[1]=1%c
f[2]=2*1%c=(2%c*f[1])%c
f[3]=3*2*1%c=(3%c*f[2])%c
f[i]=i!%c=(i%c*f[i-1])%c
8.(a-b)%c=(a%c+c-b)%c
9.long long 双长整型 printf("%lld\n",ans); 简单记忆为9e18
10.__int64 of VC is not ANSI, but you can uselong long for 64-bit integer
综上,ans=(n!-1)%(1e9+7)=(n!%(1e9+7)+1e9+7-1)%(1e9+7)=(f[n]+c-1)%c
代码:
#include<cstdio>using namespace std;long long f[100005];//f[i]=i!%c=(i%c*f[i-1])%cconst int c=1e9+7;int main(){ int t,n; long long ans;//ans=(f[n]+c-1)%c f[1]=1; for(int i=2; i<100005; i++) { f[i]=(i%c*f[i-1])%c; } scanf("%d",&t); while(t--) { scanf("%d",&n); ans=(f[n]+c-1)%c; printf("%lld\n",ans); } return 0;}
0 0
- csu 1525: Algebraic Teamwork
- Algebraic Teamwork
- Algebraic Multigrid
- 团队精神(Teamwork)
- 团队精神(Teamwork)
- Teamwork Gym
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- android开发者的42个必读网站
- 十大Intellij IDEA快捷键
- java类初始化顺序 ----需要研究的
- Android SDK开发包国内下载地址
- 3.3计算字符串的相似度
- csu 1525: Algebraic Teamwork
- 关于GPIO
- stm32 RCC 时钟分析
- 第二周项目五--数组做数据成员
- Java synchronized详解
- 去哪儿网C++笔试题--二分查找、最先出现两次的字符、每个字符串中的单词个数
- 2G模块如何实现内置协议栈上网
- 擅长排列的小明
- HDU 1702--ACboy needs your help again!【STL】