Codeforces Gym 101174 C. Candle Box
来源:互联网 发布:淘宝开店成功案例 编辑:程序博客网 时间:2024/06/15 09:36
Problem
给出 Rita
和 Theo
的年龄差 D (age[Rita] - age[Theo] = D)以及 Rita
的蜡烛数量 R, Theo
的蜡烛数量 T 。
已知 Rita 从 4 岁起、Theo 从 3 岁起(包括),每年获得等同于年龄数量的蜡烛。
Theo 将他的一些蜡烛给了 Rita 。问给了 Rita 的具体数量
限制条件
解题思路
模拟 Rita 的年龄为 age ,统计 Rita 能获得的总蜡烛数 correct
,和两人的总蜡烛数 candles
,若 candles == R+T ,则输出 R-correct
代码
#include<bits/stdc++.h>using namespace std;int main(){ int d, r, t, candles = 0, correct = 0; scanf("%d %d %d", &d, &r, &t); for(int age=1;age<=2000;age++) { if(age >= 4) candles+=age, correct += age; if(age-d >= 3) candles+=age-d; if(r+t == candles) { printf("%d\n", r - correct); return 0; } }}
阅读全文
0 0
- Codeforces Gym 101174 C. Candle Box
- CodeForces Gym 100114C
- CodeForces Gym 100735C
- codeforces Gym-101246C
- Codeforces gym 101243 C
- CodeForces Gym 100646C LCR
- Codeforces gym 101353 C 数论
- Codeforces Gym 100202C Holidays
- [Codeforces Gym] 100162A Box Game 博弈+二分图匹配
- Codeforces Gym 100623C Problem C. Class
- Codeforces Gym 100340C ePig 模拟
- Codeforces GYM 100738C Rating Shuffle
- Codeforces Gym 100792C Colder-Hotter
- Codeforces Gym 101142 C. CodeCoder vs TopForces
- Codeforces Gym 101164 C. Castle (KMP)
- Codeforces Gym 101158 C. Distribution Center
- Codeforces Gym 100642 C D F
- Codeforces Gym 101473C Boss 拓扑排序
- Axis2发布webservice(4)—WebService的session管理
- valid.js表单验证
- dedecms模板自带的网站地图如何优化?
- 关于js获取前几周,几个月的js小脚本
- 【DFS】hdu 5339 Untitled
- Codeforces Gym 101174 C. Candle Box
- PL/SQL基础
- 遇到idea提示“there is no configured/running web-servers found!”
- http访问接口自动化测试,函数封装
- 使用chukwa的自定义数据类型收集日志配置问题
- 前端开发工具sublime常用功能
- Chrome开发者工具详解(1)-Elements、Console、Sources面板
- Intellij IDEA 创建Web项目并在Tomcat中部署运行
- iOS模式详解runtime面试工作