CF 335 div.2-A/606A Magic Spheres(读错题意系列)
来源:互联网 发布:21端口查看 编辑:程序博客网 时间:2024/04/20 17:21
题目链接:http://codeforces.com/problemset/problem/606/A
题意:有蓝、紫、橙三种颜色的小球,已知各有a,b,c个,现在想要得到至少x,y,z个,其中有一个转换规则,就是消耗两个相同颜色的小球可以得到一个其他颜色的小球。给定a、b、c和x、y、z,求是否能得到想要的结果。
解:首先,读错题意系列,如果a>x&&b>y&&c>z的话,就是Yes。
否则,如果有一种颜色有少的,假设一共少m个,就是说,至少要进行m次转换。
又因为每次转换需要消耗两个相同颜色的小球,所以,计算每个颜色比最低要求多的数目,然后让这个数整除2,把所得到的相加,
若>=m,则是Yes,否则就是No。
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){//freopen("input.txt", "r", stdin);int a[3], x[3], ans = 0;for (int i = 0; i < 3; ++i)scanf("%d", &a[i]);for (int i = 0; i < 3; ++i){scanf("%d", &x[i]);if (a[i] - x[i] < 0)ans += a[i] - x[i];elseans += (a[i] - x[i]) / 2;}if (ans < 0)printf("No\n");elseprintf("Yes\n");//system("pause");//while (1);return 0;}
0 0
- CF 335 div.2-A/606A Magic Spheres(读错题意系列)
- 606A Magic Spheres
- Codeforces Round #335 (Div. 2) A. Magic Spheres 水题
- Codeforces Round #335 (Div. 2) A.Magic Spheres
- Codeforces Round #335 (Div. 2) A. Magic Spheres
- Codeforces Round #335 606A - Magic Spheres
- 【CodeForces】606A - Magic Spheres(水)
- CodeForces 606 A. Magic Spheres(水~)
- CodeForces 606A. Magic Spheres
- 【CodeForces】[606A]Magic Spheres
- Codeforces 606A Magic Spheres
- 【CodeForces 606A】Magic Spheres
- Codeforces 335A.Magic Spheres
- CodeForces 606A-A. Magic Spheres【模拟】
- A. Magic Spheres
- CodeForce--606A. Magic Spheres解题报告
- Codeforces 606A Magic Spheres 【水题】
- CodeForces 606A Magic Spheres【水题】
- TextView下划线带颜色
- js 去除数组的重复
- 僵尸进程zombie与孤儿进程orphan
- nginx之proxy_pass的session丢失
- python混合笔记(一)
- CF 335 div.2-A/606A Magic Spheres(读错题意系列)
- 知乎上关于Java Bean的比喻
- CUDA入门(10):CUDA 流
- ProgressBar的使用以及实现进度条的增减
- 关于Bean的二三事
- freemarker简单入门Demo
- FLV科普2 FLV相关工具FlvParse
- 电子电路开发基础
- 能被3和11整除吗(数论)