摘要:
#include#includeusing namespace std;const int maxn = 20;char a[maxn], b[maxn];char c[maxn];int toint(char s[]){ int j = 0; for(int i=0; i<strlen(s); i++){ if(s[i] == ',') continue; c[j++] = s[i]; } c[j] = '\0'; return atoi(c);}int main(){ while(scanf("%s%s", a, b) == 2){ 阅读全文
摘要:
题意: 如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。AC代码:#include#includeusing namespace std;const int maxn = 1000 + 10;int value[maxn];int cost[maxn];int dp[maxn][maxn];int Max(int a, int b){ return a > b ? a : 阅读全文