Algebraic Teamwork
来源:互联网 发布:网络口意什么意思 编辑:程序博客网 时间:2024/05/14 08:32
Description
Input
Output
Sample Input
3122171
Sample Output
016425
HINT
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 use long long for 64-bit integer
综上,ans=(n!-1)%(1e9+7)=(n!%(1e9+7)+1e9+7-1)%(1e9+7)=(f[n]+c-1)%c
#include<iostream>
#include<cstdio>
using namespace std;
long long g[100006];
const int x=1e9+7;
main()
{
g[1]=1;
for(int i=2;i<100006;i++)
{
g[i]=(i%x*g[i-1])%x;
}
int t,n;
long long ans;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
ans=(g[n]%x+x-1)%x;
printf("%lld\n",ans);
}
}
- Algebraic Teamwork
- csu 1525: Algebraic Teamwork
- Algebraic Multigrid
- 团队精神(Teamwork)
- 团队精神(Teamwork)
- Teamwork Gym
- lightoj1070 - Algebraic Problem(Matrix)
- LightOJ 1070 Algebraic Problem
- LIGHT OJ1070 Algebraic Problem
- LOJ 1070 Algebraic Problem
- Algebraic Problem LightOJ
- The TEAM of teamwork
- Teamwork[English Study]
- 我心中的Teamwork
- URAL 1581. Teamwork
- URAL 1581.Teamwork
- Git with TeamWork
- 备忘 amg算法 Algebraic Multigrid
- day16对于缓冲池以及自定义框架的理解
- Android Support ;v4、v7、v13的区别
- Unity3D学习(视频教程)
- Android学习系列(40)--Android主题和样式之系统篇
- MongoDB分片实战(二):Sharding 分片逻辑图
- Algebraic Teamwork
- Android_selector、shape
- MongoDB分片实战(三):性能和优化 插入、查询和更新
- [Oracle]如何在亿级记录表中创建索引
- 个人的假期学习计划
- 使用两个栈实现堆
- [Python] Python 之 __new__() 方法与实例化
- Java多线程之锁
- 夜月玥点餐售卖系统 项目展示 ShowCase2015