题意:http://acm.hdu.edu.cn/showproblem.php?pid=5976

首先队友想出了分的越多答案越多。

我们就:2,3,4,5,6.。。多出来的尽量往小了加就行了。

 #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>//freopen("C:\\Users\\13606\\Desktop\\草稿.txt","r",stdin);
#include <bitset>
//#include <map>
//#include<unordered_map>
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr
#include <string>
#include <time.h>// srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
#include <vector>//emplace_back
//#include <math.h>
#include <cassert>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
//******************
int abss(int a);
int lowbit(int n);
int Del_bit_1(int n);
int maxx(int a,int b);
int minn(int a,int b);
double fabss(double a);
void swapp(int &a,int &b);
clock_t __STRAT,__END;
double __TOTALTIME;
void _MS(){__STRAT=clock();}
void _ME(){__END=clock();__TOTALTIME=(double)(__END-__STRAT)/CLOCKS_PER_SEC;cout<<"Time: "<<__TOTALTIME<<" s"<<endl;}
//***********************
#define rint register int
#define fo(a,b,c) for(rint a=b;a<=c;++a)
#define fr(a,b,c) for(rint a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
#define ls rt<<1
#define rs rt<<1|1
typedef vector<int> VI;
typedef long long ll;
const double E=2.718281828;
const double PI=acos(-1.0);
//const ll INF=(1LL<<60);
const int inf=(<<);
const double ESP=1e-;
const int mod=(int)1e9+;
const int N=(int)1e6+; ll a[N],sum[N],up[N];
int er[]={,,,,,,,,,,,,,,,,};
ll qpow(ll a,ll b,ll mod)
{
ll ans;
// a%=mod;
ans=;
while(b!=)
{
if(b&)
ans=(ans*a)%mod;
b/=;
a=(a*a)%mod;
}
return ans;
} int main()
{
sum[]=;
up[]=;
a[]=;
for(int i=;i<=N-;++i)
a[i]=i+,sum[i]=i++sum[i-],up[i]=up[i-]*(i+)%mod;
ll x;
int T;
sc("%d",&T);
while(T--)
{
sc("%lld",&x);
if(x<=)
{
cout<<x<<endl;
continue;
}
int temp=;
for(int i=;i>=;--i)
{
if(sum[temp+er[i]]<=x)
temp+=er[i];
}
ll out=x%sum[temp];
if(temp+-out>=)
{
ll other=up[temp]*qpow(a[out?temp+-out:temp],mod-,mod)%mod;
ll ans=other*(a[out?temp+-out:temp]+out)%mod;
pr("%lld\n",ans);
}
else
{
ll other=up[temp]*qpow(,mod-,mod)%mod;
ll ans=other*(+out)%mod;
pr("%lld\n",ans);
}
}
return ;
} /**************************************************************************************/ int maxx(int a,int b)
{
return a>b?a:b;
} void swapp(int &a,int &b)
{
a^=b^=a^=b;
} int lowbit(int n)
{
return n&(-n);
} int Del_bit_1(int n)
{
return n&(n-);
} int abss(int a)
{
return a>?a:-a;
} double fabss(double a)
{
return a>?a:-a;
} int minn(int a,int b)
{
return a<b?a:b;
}

最新文章

  1. cout 格式化输出
  2. 在不知下面有几个元素的时候,要去除最后一个元素的下边框jquery代码
  3. java 网络编程复习(转)
  4. weblogic10.3.6 自动启动服务后停止的解决方案
  5. ubuntu14.04配置中文latex完美环境(texlive+texmaker+lyx)
  6. 蓝牙版本V4.2特征讲解说明
  7. 关于ORACLE DUAL表
  8. Slalom
  9. android开发者博客二月Android Studio2.0测试
  10. python none,null,,,,,类型
  11. python爬虫实战2百度贴吧爬html
  12. vue 全局插槽 全局插座
  13. python中的图像数据库PIL
  14. TP框架下载功能
  15. git如何避免push/pull时输入密码
  16. 字符编码那点事:快速理解ASCII、Unicode、GBK和UTF-8
  17. Chrome刷新缓存
  18. maven更新项目版本
  19. webpack学习笔记——解决多次输出的问题&amp;自动编译之启用观察者模式,热重载
  20. Python-WEB -VUE初识

热门文章

  1. 提交项目到Github
  2. 如何用 Windows Live Writer 和 Word 2013 分别发表博客到Cnblog 和CSDN
  3. SpringBoot使用Undertow做服务器
  4. super关键字和调用父类构造方法
  5. Open Live Writer 显示不出来代码着色插件解决办法
  6. 通过JDBC API访问数据库的基本步骤
  7. 【Centos】搭建 SVN 服务器
  8. 重新部署环境之后,总是提示表doesn't have a default value
  9. mac-chrome下手动安装vue-devtools
  10. git如何添加子模块以便方便使用别人维护的模块?