Codeforces Round #236 (Div. 2)A(贪心、数学)
来源:互联网 发布:麦茶 日本 知乎 编辑:程序博客网 时间:2024/04/30 19:33
题目链接:http://codeforces.com/contest/402/problem/A
解题思路:
一路贪心,把条件判断好即可。
完整代码:
#include <algorithm>#include <iostream>#include <cstring>#include <complex>#include <cstdio>#include <string>#include <cmath>using namespace std;typedef long long LL;const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const double EPS = 1e-9;const double PI = acos(-1.0); //M_PI;int main(){ #ifdef DoubleQ freopen("in.txt","r",stdin); #endif std::ios::sync_with_stdio(false); std::cin.tie(0); int k , a , b , v; while(cin >> k >> a >> b >> v) { int cnt = 0; while(a > 0) { if(b == 0) a -= v; else { if(b >= k - 1) { a -= k * v; b -= k - 1; } else { a -= (b + 1) * v; b = 0; } } cnt ++; } cout << cnt << endl; }}
0 0
- Codeforces Round #236 (Div. 2)A(贪心、数学)
- Codeforces Round #342 (Div. 2)(A)贪心,数学
- Codeforces Round #392 (Div. 2) A(水)B(水、模拟) C(数学) D(贪心)
- Codeforces Round #199 (Div. 2) A ( 简单贪心 )
- Codeforces Round #260 (Div. 2) A (贪心)
- Codeforces Round #111 (Div. 2) A Twins (贪心)
- Codeforces Round #279 (Div. 2)---A. Team Olympiad (贪心)
- Codeforces Round #303 (Div. 2) A - Equidistant String(贪心)
- Codeforces Round #340 (Div. 2)-A. Elephant(贪心)
- Codeforces Round #202 (Div. 2)(A)贪心
- Codeforces Round #311 (Div. 2)(A)贪心
- codeforces Round #364(Div.2)701A Cards 贪心算法
- Codeforces Round #436 (Div. 2)-贪心-D. Make a Permutation!
- Codeforces Round #133 (Div. 2) A. Tiling with Hexagons(数学)
- Codeforces Beta Round #4 (Div. 2) / 4A Watermelon(数学)
- Codeforces Round #188 (Div. 2) A(数学划分)
- Codeforces Round #195 (Div. 2) A.(数学枚举)
- Codeforces Round #276 (Div. 2)A. Factory 数学+规律
- ZgiBee读取温度电量信息
- 机器学习资料
- 学习Scala的一些参考资料
- LeetCode
- 虚拟机VMware Workstation 安装Mac OS X10.10.1 和 Xcode6.1
- Codeforces Round #236 (Div. 2)A(贪心、数学)
- 一位IT牛人的十年经验之谈
- 网络抓包工具charles
- Prolific USB-to-Serial Comm Port在win8.1下
- 完数
- 蓝桥杯 基础练习 闰年判断
- window.showmodaldialog undefined is not a function
- 黑马程序员---NSString和NSMutableString
- 工作日志