标签:algorithm ring closed efi scan ace names ++ get
https://ac.nowcoder.com/acm/contest/910/B
本以为是组合数,没想到是dp求解,变成水题了,让我想起了第一次见到dp的爬楼梯,可以走一步和走两步,走40步,这里相当于走13种不同的步数,走100000步。
#include<stdio.h> #include<math.h> #include<string.h> #include<algorithm> #include<string> #include<vector> #include<iostream> #include<set> #include<cstring> #include<queue> #include<map> #define inf 0x3f3f3f3f #define ll long long using namespace std; const int p=1e9+7; int a[13]={1,2,5,10,20,50,100,200,500,1000,2000,5000,10000}; int dp[100086]; int main() { memset(dp,0,sizeof(dp)); dp[0]=1; for(int i=0;i<13;i++) { for(int j=a[i];j<=100000;j++) dp[j]=( dp[j] + dp[ j-a[i] ] )%p; } int n,t; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n",dp[n]); } return 0; }
标签:algorithm ring closed efi scan ace names ++ get
原文地址:https://www.cnblogs.com/shoulinniao/p/10928542.html