题意: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;
}

N分成不同的数相乘使答案最大的更多相关文章

  1. Java 递归解决 &quot;仅仅能两数相乘的计算器计算x^y&quot; 问题

    /** * 求一个数的乘方 * 求x^y,y是一个正整数. 设计算器仅仅能计算两数相乘,不能一次计算n个数相乘. * 知:2^5=(2^2)^2*2; 2^6=(2^2)^3=((4)^2)*4; 2 ...

  2. java两数相乘基础算法

    下面是别人给我的代码: package com.bootdo; public class Test { public static void main(String[] args) { System. ...

  3. C语言100题集合005-删除一维数组中所有相同的数,使之只剩一个

    系列文章<C语言经典100例>持续创作中,欢迎大家的关注和支持. 喜欢的同学记得点赞.转发.收藏哦- 后续C语言经典100例将会以pdf和代码的形式发放到公众号 欢迎关注:计算广告生态 即 ...

  4. 使用OC语言编写两个超大数相乘或相加的算法的思路和超大正整数相乘的代码

    正文: 在编程中,无论是OC还是C亦或是C++语言,所声明的整数变量都会在内存中占有固定的存储空间,而这些存储空间都是固定的. 比如我们知道的int.long.short.unsigend int.u ...

  5. 【BZOJ1594】[Usaco2008 Jan]猜数游戏 二分答案+并查集

    [BZOJ1594][Usaco2008 Jan]猜数游戏 Description 为了提高自己低得可怜的智商,奶牛们设计了一个新的猜数游戏,来锻炼她们的逻辑推理能力. 游戏开始前,一头指定的奶牛会在 ...

  6. openjudge 和为给定数(二分答案)

    嗯... 题目链接:http://noi.openjudge.cn/ch0111/07/ 这道题是一道不太明显,但很好二分的二分答案的一道题... 首先排序(二分要满足单调性),然后枚举每一个数,在[ ...

  7. 从一个n位数中选出m位按顺序组成新数并使其最大 || Erasing and Winning UVA - 11491

    就是从n位数中取出n-d个数字按顺序排成一排组成一个新数使得其最大 算法: 从前往后确定每一位.找第i位时,要求后面留下d-i位的空间, 因此第i位应该从第i-1位原来位置+1到第d+i位寻找 用线段 ...

  8. A<=B的前提下全排列A使答案尽量大

    题意:http://codeforces.com/problemset/problem/915/C 举个例子:假使排好序后a字符串是123456,b是456456,按照上述方法遍历,213456 -& ...

  9. python 用加法实现a,b两数相乘

    """思路:1.a * b = a + a + a + ... 2.a * b = n个a相加,只需求证b = n即可 3.用for 循环遍历即可,b就是range的最大 ...

随机推荐

  1. Python互联网金融之用户增长的数据逻辑

    怎样看待和应用我们互联网金融中的数据? 怎样进行数据分析? 互联网金融数据分析的三个层面: (1)指标层面 建立指标体系,观察指标涨跌的情况 (2)行业框架 不同的行业对于各个指标的权重不同 复投率 ...

  2. UOJ #164 [清华集训2015]V (线段树)

    题目链接 http://uoj.ac/problem/164 题解 神仙线段树题. 首先赋值操作可以等价于减掉正无穷再加上\(x\). 假设某个位置从前到后的操作序列是: \(x_1,x_2,..., ...

  3. 5.4.2 mapFile读写和索引

    5.4.2         mapFile (1)定义 MapFile即为排序后的SequeneceFile,将sequenceFile文件按照键值进行排序,并且提供索引实现快速检索. (2)索引 索 ...

  4. CentOS7.4搭建ftp服务

    1.使用yum安装vsftpd yum install vsftpd -y 2.安装完成后,启动 FTP 服务: service vsftpd start 3.配置ftp权限 目前 FTP 服务登陆允 ...

  5. cxf报错 Cannot find any registered HttpDestinationFactory from the Bus.

    错误信息:Cannot find any registered HttpDestinationFactory from the Bus. 报错主要是因为缺少jetty依赖 一般添加如下依赖即可 < ...

  6. 感知机和BP神经网络

    一.感知机 1.感知机的概念 感知机是用于二分类的线性分类模型,其输入是实例的特征向量,输出是实例的类别,类别取+1和-1二个值,+1代表正类,-1代表负类.感知机对应于输入空间(特征空间)中将实例分 ...

  7. PHP学习之工厂模式

    <?php //工厂模式 interface Doing { function eat(); function sleep(); } class Cat implements Doing { f ...

  8. Vue于React特性对比(三)

    最近重学React,再次和vue做了对比. 一,为官方插件提供便利的第三方插件横行 React仅仅是一个ui框架.虽然官方提供了redux,react-router:但也有第三方的redux-thun ...

  9. centos 开启关闭网卡

    ifdown ifcfg-enp7s0 关闭网卡 ifup ifcfg-enp7s0 开启网卡

  10. TortoiseSVN commit 停止工作

    TortoiseSVN commit 便停止工作,详细原因是igc64.dll故障,该动态链接库与Intel HD Graphics Driver有关(即显卡驱动),由于重装系统后,进行了显卡驱动的更 ...