## 1263: [SCOI2006]整数划分

Time Limit: 1 Sec  Memory Limit: 162 MB
Submit: 677  Solved: 332
[Submit][Status]

13

3
108

## Source

``` #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 5000+100
#define maxm 500+100
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define mod 10
using namespace std;
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
int n,a[maxn];
void mul(int x)
{
for1(i,a[])a[i]*=x;
for1(i,a[])
{
a[i+]+=a[i]/mod;
a[i]%=mod;
}
while(a[a[]+])a[]++;
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
a[a[]=]=;
if(n%==)for1(i,n/)mul();
else if(n%==)
{
for1(i,(n/-))mul();
mul();
}
else
{
for1(i,n/)mul();
mul();
}
printf("%d\n",a[]);
for3(i,a[],max(a[]-+,))printf("%d",a[i]);
printf("\n");
return ;
}```