标签:size sizeof freopen pair out list memset ems 练习
链接:https://www.nowcoder.com/acm/contest/110/A
来源:牛客网
题目描述
这题要你回答T个询问,给你一个正整数S,若有若干个正整数的和为S,则这若干的数的乘积最大是多少?请输出答案除以2000000000000000003(共有17 个零) 的余数。
举例来说,当 S = 5 时,若干个数的和为 5 的情形有以下 7 种(不考虑数字的顺序的话):
【知乎讲解】
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<cstring>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>
#include<cctype>
#include<stack>
#include<sstream>
#include<list>
#include<assert.h>
#include<bitset>
#include<numeric>
#define debug() puts("++++")
#define gcd(a,b) __gcd(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x)*(x))
#define ms(a,b) memset(a,b,sizeof(a))
#define sz size()
#define be begin()
#define pu push_up
#define pd push_down
#define cl clear()
#define lowbit(x) -x&x
#define all 1,n,1
#define mod 2000000000000000003
#define rep(i,n,x) for(int i=(x); i<(n); i++)
#define in freopen("in.in","r",stdin)
#define out freopen("out.out","w",stdout)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e18;
const int MAXN = 1e3 + 5;
const int maxm = 1e6 + 10;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int dx[] = {-1,1,0,0,1,1,-1,-1};
const int dy[] = {0,0,1,-1,1,-1,1,-1};
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
/*
long long Pow(long long a,long long b)
{
long long res=1;
for(int i=1;i<=b;i++){
res*=a; res %= 2000000000000000003;
}
return res;
}
*/
/*
LL mul(LL a,LL b)
{
LL ans=0;
while(b)
{
if(b&1) ans=(ans+a)%p;
a=(a+a)%p;
b=b>>1;
}
return ans;
}
LL Pow(LL a,LL b)
{
LL result=1;
LL base=a%p;
while(b)
{
if(b&1) result=mul(result,base)%p;
base=mul(base,base)%p;
b=b>>1;
}
return result;
}
*/
int main()
{
long long ans, n;
int t;
cin>>t;
while(t--){
ans = 1;
cin >> n;
while(n>4){
ans=ans*3%mod;
n-=3;
cout<<ans<<endl;
}
ans=ans*n%mod;
cout<<ans<<endl;
}
return 0;
}
牛客网练习赛18 A 【数论/整数划分得到乘积最大/快速乘】
标签:size sizeof freopen pair out list memset ems 练习
原文地址:https://www.cnblogs.com/Roni-i/p/9058388.html