Codeforces Round #190 (Div. 2) 水果俩水题
后天考试,今天做题,我真佩服自己。。。
这次又只A俩水题。。。
orz各路神犇。。。
话说这次模拟题挺多。。。
半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来。。。
A:
算是模拟吧,反正看懂题目后很可耻的生硬水果,没被hack我觉得非常开心。。。
由于要求两个人至少一个没跳过,画图后发现很偷懒的方法。
虽然跟样例不同,但过了。。。
#include <cstdio>
int main() {
int n, m;
scanf("%d%d", &n, &m);
printf("%d\n", n + m - 1);
for (int i = 1; i <= m; i++)
printf("1 %d\n", i);
for (int i = 2; i <= n; i++)
printf("%d 1\n", i);
return 0;
}
B:
本来直接全部做成最大纯色,然后考虑杂色,wa了。
发现想错了,比如3 5 5,如果按原来想法会得出3,而它可以先做两个纯色为3 2 2,然后做2个混色为1 0 0。
于是想出算法,比赛时没被room里面的大神没被hack,事后发现过不了新加的数据15。。。
太晚碎觉,明天看吧。。。
下面是原来的代码:
#include <cstdio>
long min(long a, long b, long c)
{
if (a > b)
a = b;
if (c > a)
c = a;
return c;
}
int main() {
long r, g, b;
long sum = 0;
scanf("%ld%ld%ld", &r, &g, &b);
sum += r/3 + g/3 + b/3;
r % 3 == 0 ? r = 3, sum-- : r = r % 3;
g % 3 == 0 ? g = 3, sum-- : g = g % 3;
b % 3 == 0 ? b = 3, sum-- : b = b % 3;
sum += min(r, g, b);
printf("%ld\n", sum);
return 0;
}
重判错了,发现两个错误:
当min(1, 3, 3)时返回1,其实可以做出两个的,于是改了下。
当输入里面有0时会出错(感谢@CS_liuqing 童鞋的指出)。
修改后A过了(蒻菜的代码很蒻):
#include <cstdio>
long func(long a, long b, long c)
{
if ((c == 1 && a == 3 && b == 3) || (b == 1 && a == 3 && c == 3) || (a == 1 && b == 3 && c == 3))
return 2;
if (a > b)
a = b;
if (c > a)
c = a;
return c;
}
int main() {
long r, g, b;
long sum = 0;
scanf("%ld%ld%ld", &r, &g, &b);
sum += r/3 + g/3 + b/3;
if (r && g && b) {
r % 3 == 0 ? r = 3, sum-- : r = r % 3;
g % 3 == 0 ? g = 3, sum-- : g = g % 3;
b % 3 == 0 ? b = 3, sum-- : b = b % 3;
sum += func(r, g, b);
printf("%ld\n", sum);
}
else
printf("%ld\n", sum);
return 0;
}
C:
模拟题,其实不是。。。模拟起来必须超时。。。
思路到后面已经有了,拖拉太久时间不够。
三鲜大神说:A 的意思就是 kx + b = y,判断整除就可以了。
膜拜中。
这里是只水水题的水果君,转载请注明。
http://blog.csdn.net/hcbbt
Codeforces Round #190 (Div. 2) 水果俩水题的更多相关文章
- Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告
对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...
- Codeforces Round #340 (Div. 2) B. Chocolate 水题
B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...
- Codeforces Round #340 (Div. 2) A. Elephant 水题
A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...
- Codeforces Round #340 (Div. 2) D. Polyline 水题
D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...
- Codeforces Round #338 (Div. 2) A. Bulbs 水题
A. Bulbs 题目连接: http://www.codeforces.com/contest/615/problem/A Description Vasya wants to turn on Ch ...
- Codeforces Round #282 (Div. 1) A. Treasure 水题
A. Treasure Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/494/problem/A ...
- Codeforces Round #327 (Div. 2) B. Rebranding 水题
B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...
随机推荐
- 集合-Collection
集合中存放的依然是对象的引用,而不是对象本身 ArrayList: 1) ArrayList底层使用数组实现,当使用不带参数的构造方法生成ArrayList对象时,实际上会在底层生成一个长度为10的O ...
- HDFS体系结构
HDFS的设计目标 检测以及快速恢复硬件问题. 流式的数据访问. 移动计算比移动数据的代价小. 简化一致性模型. 超大规模数据集 异构软硬件平台之间的可移植性. HDFS的结构模型HDFS是一个主从的 ...
- [置顶] Kendo UI开发教程: Kendo UI 示例及总结
前面基本介绍完Kendo UI开发的基本概念和开发步骤,Kendo UI的示例网站为http://demos.kendoui.com/ ,包含了三个部分 Web DemoMobile DemoData ...
- 设置结点的ID为固定ID
https://www.java.net//forum/topic/jxta/jxta-community-forum/how-initialize-pse-jxse-27 ————————————— ...
- URAL 2037 Richness of binary words (回文子串,找规律)
Richness of binary words 题目链接: http://acm.hust.edu.cn/vjudge/contest/126823#problem/B Description Fo ...
- 应用JConsole学习Java GC
应用JConsole学习Java GC 关于Java GC的知识,好多地方都讲了很多,今天我用JConsole来学习一下Java GC的原理. GC原理 在我的上一篇中介绍了Java运行时数据区,在了 ...
- C#学习笔记(十四):GC机制和弱引用
垃圾回收(GC) 垃圾回收即Garbage Collector,垃圾指的是内存中已经不会再使用的对象,通过收集释放掉这些对象占用的内存. GC以应用程序的root为基础,遍历应用程序在Heap上动态分 ...
- 修改mysql字符编码出现Job failed to start解决办法
从网上找到如下资料: $sudo gedit /etc/mysql/my.cnf [client]下添加: default-character-set=utf8 [mysqld]下添加: de ...
- iPhone Push消息全攻略.1
要做一个iPhone Push消息的需求,从简单test的开始. 1.先添加一个app ID 2.点击Edit来配置push服务. 3.生成两个证书,一个用于开发,一个用于发布. 4.按下图操作创建一 ...
- 教你50招提升ASP.NET性能(十六):把问题仍给硬件而不是开发人员
(27)Throw hardware at the problem, not developers 招数27: 把问题仍给硬件而不是开发人员 As developers, we often want ...