Detachment
来源:互联网 发布:大连交通大学网络 编辑:程序博客网 时间:2024/06/06 01:18
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<cmath>#include<iostream>using namespace std;#define maxn 50000const int mod = 1e9+7;typedef __int64 LL;LL sum[maxn];LL mu[maxn];void init(){ mu[1]=1; for(int i=2; i<maxn; i++) { sum[i]=sum[i-1]+i; mu[i]=(mu[i-1]*i)%mod; } sum[1]=1;}LL mult(LL a,int n) // 快速幂{ LL ans=1; while(n) { if(n&1)ans=(ans*a)%mod; a=(a*a)%mod; n>>=1; } return ans;}int main(){ init(); int T; scanf("%d",&T); while(T--) { LL x; scanf("%I64d",&x); int index=lower_bound(sum,sum+maxn,x)-sum; LL ans; if(sum[index]==x) ans=mu[index]; else { if(sum[index]==x+1) ans=((mu[index+1]*mult(index,mod-2))%mod*mult(2,mod-2))%mod; else ans=(mu[index]*mult(sum[index]-x,mod-2))%mod; } printf("%I64d\n",ans); } return 0;}
阅读全文
0 0
- Detachment
- HDU5976 Detachment
- HDU 5976 Detachment
- HDU 5976 Detachment
- HDOJ 5976 Detachment
- HDU 5976 Detachment
- hdoj 5976 Detachment
- hdu 5976 Detachment
- HDU 5976 Detachment
- HDU 5976 Detachment
- HDU 5976 Detachment 逆元
- 【数论】【逆元】【贪心】HDU5976 Detachment
- hdu 5976 Detachment(数论,一个结论)
- hdu 5976 Detachment 逆元+二分+数学
- HDU 5976 Detachment (逆元)
- 2016ICPC大连站 F Detachment【数学】
- HDU 5976 Detachment (数学规律+逆元)
- HDOJ 5976 Detachment【2016大连现场】【数学好题】
- [随笔一写]--在本科的第一个月
- javascript_01
- 串口通讯介绍(有见地,学法可取)
- Spring入门(AOP API、ProxyFactoryBean其一)
- eclipse使用教程(图文)
- Detachment
- Ajax动态拼接HTML,JS失效的解决——Jquery的事件委托
- Shell函数返回探究
- Android:Android应用和开发环境
- maven项目update后jdk版本变为1.5
- python爬取m3u8连接的视频
- Python中通过requests模块发送POST请求.
- Web基础 网页的骨骼HTML
- Bootstrap下拉菜单