Codeforces Round #256 (Div. 2)
2014-07-18 09:55
295 查看
A - Rewards
水题,把a累加,然后向上取整(double)a/5,把b累加,然后向上取整(double)b/10,然后判断a+b是不是大于n即可
深度搜索+剪枝
水题,把a累加,然后向上取整(double)a/5,把b累加,然后向上取整(double)b/10,然后判断a+b是不是大于n即可
#include <iostream> #include <vector> #include <algorithm> #include <vector> #define LL long long using namespace std; LL limit = 1e5; vector<LL> divs,res; bool solve(LL x, LL k){ if(k == 0 || x == 1){ res.push_back(x); return res.size() >= limit; } for(int i = 0 ;i < divs.size(); ++ i){ if(divs[i] > x) break; if(x%divs[i] == 0){ if(solve(divs[i],k-1)) return true; } } return false; } int main(){ LL x,k; cin >> x >> k; for(LL i = 1; i*i <= x; ++ i){ if(x%i == 0){ divs.push_back(i); if(i*i != x) divs.push_back(x/i); } } sort(divs.begin(),divs.end()); solve(x,k); for(int i = 0 ; i < res.size(); ++ i){ if(i) cout<<" "; cout<<res[i]; } cout<<endl; return 0; }
深度搜索+剪枝
相关文章推荐
- Codeforces Round #256 (Div. 2) D. Multiplication Table
- Codeforces Round #256 (Div. 2) B
- Codeforces Round #256 (Div. 2)思维训练
- Codeforces Round #256 (Div. 2) #B Suffix Structures
- Codeforces Round #256 (Div. 2) B. Suffix Structures
- Codeforces Round #256 (Div. 2) A Rewards
- Codeforces Round #256 (Div. 2) D. Multiplication Table(二分查找)
- Codeforces Round #256 (Div. 2) B Suffix Structures
- Codeforces Round #256 (Div. 2) Multiplication Table
- Codeforces Round #256 (Div. 2) C. Painting Fence
- Codeforces Round #256 (Div. 2) D Multiplication Table
- Codeforces Round #256 (Div. 2)总结
- Codeforces Round #140 (Div. 2) A. Where do I Turn?
- Codeforces Round #379 (Div. 2) F
- Codeforces Round #353 (Div. 2) E. Trains and Statistic dp 贪心
- Codeforces Round #322 (Div. 2) —— F. Zublicanes and Mumocrates
- Educational Codeforces Round 40 (Rated for Div. 2) B. String Typing
- Codeforces Round #305 (Div. 2) C. Mike and Frog +B. Mike and Fun
- Codeforces Round #202 (Div. 2) B.Color the Fence
- Codeforces Round #240 (Div. 2) C Mashmokh and Numbers