2013年8月19日

Codeforces 106 C 多重背包

摘要: 题目链接:http://codeforces.com/problemset/problem/106/C根据题意列出式子,设每种蛋糕做了xi个,则对于每种材料bi*xi 2 #include 3 #define INF 0x3f3f3f3f 4 #define N 1005 5 int f[N],s[N]; 6 struct bake 7 { 8 int val,we; 9 } p[12*N];10 int main()11 {12 int n,m,we,val,cnt=0;13 scanf("%d%d%d%d",&n,&m,&we,&val) 阅读全文

posted @ 2013-08-19 20:43 allh123 阅读(288) 评论(0) 推荐(0) 编辑

beautiful number 数位DP codeforces 55D

摘要: 题目链接:http://codeforces.com/problemset/problem/55/D数位DP题目描述:一个数能被它每位上的数字整除(0除外),那么它就是beautiful number。问区间[a,b]上有多少个beautiful number。如102就是一个beautiful number,因为它能整除1,2。14不是,因为14不能整除4.解法:数位DP,设dp[i][j][k]为累计到第i为,公倍数为j,模lcm(1,2,```,9)=2520的余数为k的数的个数。注意到两个事实,要求某个数能整除它的每一个非0位上的数字,那么等价于将这些数字求一个最小公倍数,如果这个数能 阅读全文

posted @ 2013-08-19 16:34 allh123 阅读(188) 评论(0) 推荐(0) 编辑

导航