set
来源:互联网 发布:linux wget 批量下载 编辑:程序博客网 时间:2024/06/05 05:54
所以说不要以为前一天考了什么后一天就不会考这类的东西了
出题人总是能竭尽所能
打破你的下限qaq
naive
我本来是以为昨天已经考过一道大家什么都没学的数学题
这事儿就这么完了
可惜没有qwq
解释一部分来自题解 一部分来自自己
写写划划试几个小的数据应该有助于理解
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<string>#define ll long long#define maxn 100100using namespace std;const int mod=(1000000000+7);ll jc[maxn];ll qpow(ll x,ll y){ ll ans=1; for (;y;y>>=1,x*=x){x%=mod; if (y&1) ans*=x; ans%=mod;} return ans;}ll inv(ll a){ return qpow(a,mod-2);}int main(){ //freopen ("set.in","r",stdin); //freopen ("set1.out","w",stdout); int n; scanf ("%d",&n); jc[0]=1; /*设最后都收束为p,显然f(p)=p。 设有L个f(x)=p,除了p还要任选L-1个, 剩下n-L个都要在这L-1个位置中任取。枚举L, 复杂度O(n) f(n-L) -> L-1种值*/ for (int i=1;i<=n;++i) jc[i]=(jc[i-1]*i)%mod; ll ans=0; for (int l=1;l<=n;++l){ //n-1里选l-1个数u ll as=jc[n-1]*inv(jc[l-1])%mod*inv(jc[n-l])%mod; //把n-l个数放进l-1个位置里 ll am=qpow(l-1,n-l); ans=(as*am%mod)+ans; ans%=mod; } ans=ans*n%mod; cout<<ans; return 0; }
然后这次求逆元用的是费马小定理 (其实上次也可以
快速幂打wa+mod 没打括号改了40分钟也是没谁了(仰胁息
考场想出了组合然而那时候也是不会逆元的
也不知道可以quickpow一下(sb
感觉解释还是讲得满清楚的
一定记得有事没事就膜膜膜 (gouliguojia)
为出题人+1s
0 0
- set /?
- Set
- set
- set
- set
- Set
- set
- Set
- Set
- set
- set
- Set
- set
- Set
- set
- Set
- set
- Set
- 【codevs1907】[网络流24题]方格取数3
- 【C语言简单说】六:取模运算符以及变量的扩展
- 自定义控件:视差特效
- Spring进阶之自定义标签实现
- Android之SwipeRefreshLayout下拉刷新组件
- set
- Android获取当前连接wifi的信道
- SQL常见的一些面试题(太有用啦)
- codeforces 721C DAG上dp
- AFO(3)
- 单例模式
- 使用scorllLeft实现轮播代码
- In 7-bit zoj3713 (位运算+进制转换,水)
- sqlalchemy一些用法整理