# Bzoj2822 [ahoi2012]树屋阶梯

Posted by yjjr's blog on February 6, 2018

Description

以树屋高度为4尺、阶梯高度N=3尺为例，小龙一共有如图1.2所示的5

搭 建方法：

Input

Output

Sample Input

3

Sample Output

5

HINT

1  ≤N≤500

Code

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define LL long long
#define mem(x,num) memset(x,num,sizeof x)
using namespace std;
{
LL f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const LL maxn=1e6+6;
LL prime[maxn],mn[maxn],n,cnt=0,num[maxn],ans[maxn];
bool not_prime[maxn];
inline void getpri()
{
rep(i,2,2*n){
if(!not_prime[i]){prime[++cnt]=i;mn[i]=cnt;}
for(int j=1;j<=cnt&&i*prime[j]<=2*n;j++){
not_prime[i*prime[j]]=1;mn[i*prime[j]]=j;
if(i%prime[j]==0)break;
}
}
}
{
while(x!=1){
num[mn[x]]+=f;
x/=prime[mn[x]];
}
}

inline void Mul(int x)
{
rep(i,1,ans[0])ans[i]*=x;
rep(i,1,ans[0]-1){
ans[i+1]+=ans[i]/10;
ans[i]%=10;
}
while(ans[ans[0]]>9){
ans[ans[0]+1]=ans[ans[0]]/10;
ans[ans[0]]%=10;ans[0]++;
}
}

int main()
{
getpri();