P6205 [USACO06JAN]Dollar Dayz S

Aimee

他的状态转移有手就行

但是需要写高精

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<bits/stdc++.h> 
using namespace std;
struct Aimee{
	int len;
	int a[1001];
}f[1001];
int n,k;
Aimee  operator + (const Aimee &x,const Aimee &y){
	Aimee tem;
	int l=max(x.len,y.len);
	int u=0;
	for(int i=1;i<=l;++i){
		tem.a[i]+=x.a[i]+y.a[i];
		tem.a[i+1]+=(tem.a[i]/10);
		tem.a[i]%=10; 
	}
	if(tem.a[l+1]!=0){
		tem.len=l+1;
	}else{
		tem.len=l;
	}
	return tem;
}
void Ar(){
	for(int i=f[n].len;i;--i){
		cout<<f[n].a[i];
	}
}
int main(){
	scanf("%d%d",&n,&k);
	f[0].len=1;
	f[0].a[1]=1;
	cout<<f[10].len<<endl;
	for(int i=1;i<=k;++i){
		for(int j=i;j<=n;++j){
			f[j]=f[j]+f[j-i];
		}
	}
	Ar(); 
	return 0;
}

posted @ 2020-11-05 21:53  Simex  阅读(75)  评论(0编辑  收藏  举报