#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
#include<assert.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
const int N = 0, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
int main()
{
int T; scanf("%d", &T); assert(T >= 1 && T <= 10);
while (T--)
{
int n; scanf("%d", &n); assert(n >= 1 && n <= 1e6);
putchar('1');
while (--n) putchar('0');
puts("");
}
return 0;
}
/*
【题意】
一开始有数量为n(1<=n<=1e6)的水,
我们每天可以喝数量为任意整数的水,问你有多少种方式可以把水喝完。
【类型】
简单排列组合 隔板法
【分析】
这道题其实就是——
问你,对于整数n,可以把n拆分成多少个不同的正整数序列
我们考虑排列组合中的隔板法。
就是n个数,中间有n-1个空位,
其中每一个空位中,都可以选择插入隔板,从而把这n个数分成若干份,恰好对应本题。
显然——
如果拆成1份,方案数是C(n-1,1-1)=C(n-1,0)
如果拆成2份,方案数是C(n-1,2-1)=C(n-1,1)
如果拆成3份,方案数是C(n-1,3-1)=C(n-1,2)
...
如果拆成n份,方案数是C(n-1,n-1)=C(n-1,n-1)
对应着二项式展开,它们的和恰好是2^(n-1)。
于是对应着,我们直接输出——
1个1
+(n-1)个0即可。
【时间复杂度&&优化】
O(n)
*/
【2016杭电女生赛1002】【排列组合 隔板法】Desert 对n做正整序列拆分的方案数
最新推荐文章于 2021-08-11 22:46:19 发布