Codeforces Round #119 (Div. 2) A题
2013-10-11 17:28
281 查看
/* 当我看到这题时,我懂意思了,题意就是:给你一条长度n的丝带,然后让你切断,但是切断 后的丝带长度必须是给出的三个数据中的长度。 题目意思很简单,可我却没有什么思路,傻逼了,后来看了别人的解题报告, 发现自己真心好水啊!!抓狂!!! 暴力来做,也叫枚举,先枚举 a 和 b 的数量 然后再算 C 数量,然后进行比较 就可以计算出结果!!! */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n,a,b,c; int main() { int i,j,maxn; while(scanf("%d%d%d%d",&n,&a,&b,&c)!=EOF) { maxn=0; for(i=0; i*a<=n; i++) { for(j=0; (i*a+j*b)<=n; j++) { if((n-i*a-j*b)%c==0) { maxn=max(maxn,i+j+(n-i*a-j*b)/c); } } } printf("%d\n",maxn); } return 0; }
相关文章推荐
- Codeforces Round #119 (Div. 2) Cut Ribbon(DP)
- Codeforces Round #119 (Div. 2) / 189A Cut Ribbon (完全背包)
- Codeforces Round #119 (Div. 1) B. AlgoRace
- Codeforces Round #119 (Div. 2) B. Counting Rhombi
- Codeforces Round #119 (Div. 2) A. Cut Ribbon
- Codeforces Round #119 (Div. 2)A. Cut Ribbon
- codeforces round 119 div2 A-D
- Codeforces Round #398 (Div. 2)C
- Codeforces Round #443 (Div. 2) A. Borya's Diagnosis
- Codeforces Round #FF (Div. 2):B. DZY Loves Strings
- Codeforces Round #174 (Div. 2)---D. Cow Program(dp, 记忆化搜索)
- CodeForces AIM Tech Round 3 (Div. 1) 题解(CF708A,CF708B,CF708C,CF708D,CF708E)
- Codeforces Round #135 (Div. 2)---A. k-String
- Codeforces Round #FF(255) DIV2
- Codeforces Round #464 (Div. 2) A Determined Cleanup
- Codeforces Round #FF (Div. 2)C.DYZ Loves Sequence
- Codeforces Round #186 (Div. 2).D
- CodeForces round 428 div2 only
- 想法题——Codeforces Round #190 (Div. 2)——B. Ciel and Flowers
- Codeforces Round #FF (Div. 二):C. DZY Loves Sequences