水题Eating Soup
A. Eating Soup
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
The three friends, Kuro, Shiro, and Katie, met up again! It’s time for a party…
What the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now n cats are at the party, sitting in a circle and eating soup. The rules are simple: anyone having finished their soup leaves the circle.
Katie suddenly notices that whenever a cat leaves, the place where she was sitting becomes an empty space, which means the circle is divided into smaller continuous groups of cats sitting next to each other. At the moment Katie observes, there are m cats who left the circle. This raises a question for Katie: what is the maximum possible number of groups the circle is divided into at the moment?Could you help her with this curiosity?You can see the examples and their descriptions with pictures in the “Note” section.
Input
The only line contains two integers n and m (2≤n≤1000, 0≤m≤n) — the initial number of cats at the party and the number of cats who left the circle at the moment Katie observes, respectively.
Output
Print a single integer — the maximum number of groups of cats at the moment Katie observes.
Examples
inputCopy
7 4
outputCopy
3
inputCopy
6 2
outputCopy
2
inputCopy
3 0
outputCopy
1
inputCopy
2 2
outputCopy
0
题意:题目的意思就是说,有n只猫,围在一起喝汤,喝完了就可以走m只,最后可以围成的多少组
思路:当一只猫都没走的时候,还是一圈只有一个组;
当剩下的猫大于走的猫的时候,这时候能围成m组;
当剩下的猫小于走的猫的时候,这时候能围成n-m组;
水题一道,哎,特此记录一下
#include"iostream"
#include"algorithm"
#include"cstdio"
#include"cstring"
#include"string.h"
using namespace std;
int main(){
int n,m;
while(cin>>n>>m){
if(m==)
cout<<""<<endl;
else if(n-m>=m)
cout<<m<<endl;
else
cout<<n-m<<endl;
}
return ;
}
//不要脸的贴个网上代码
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
cin>>n>>m;
cout<<min(n-m,max(,m));
}
水题Eating Soup的更多相关文章
- BZOJ USACO 银组 水题集锦
最近刷银组刷得好欢快,好像都是水题,在这里吧他们都记录一下吧(都是水题大家一定是道道都虐的把= =)几道比较神奇的题到时再列出来单独讲一下吧= =(其实我会说是BZOJ蹦了无聊再来写的么 = =) [ ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,
1195: 相信我这是水题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 821 Solved: 219 Description GDUT中有个风云人 ...
- BZOJ 1303 CQOI2009 中位数图 水题
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2340 Solved: 1464[Submit][Statu ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- ACM水题
ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...
随机推荐
- 1级搭建类111-Oracle 19c SI FS(Windows Server 2019)公开
Oracle 19c 单实例文件系统在Windows Server 2019上的安装 在线查看
- ZedGraph怎样在双击图形后添加箭头标记
场景 在ZedGraph的曲线图上,双击图时会在图形上生成箭头符号标记. 效果 注: 博客主页: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的 ...
- Java连载85-集合的Contains和Remove方法
一.包含与删除两种方法解析 1.boolean contains(Object o);判断集合中是否包含某个元素. package com.bjpowernode.java_learning; imp ...
- 跳表的java实现,转载自网络,仅供自己学习使用
文档结构: 1.代码结构 2.代码实现 1.代码结构 节点类: String key 键值 对跳跃表的操作都是根据键值进行的 Int value 实际值 Node up,down,left,rig ...
- Cannot resolve collation conflict between "Chinese_Taiwan_Stroke_CI_AS" and "Chinese_PRC_CI_AS" in UNION ALL operator occurring in SELECT statement column 1.
Cannot resolve collation conflict between . 解决方案: COLLATE Chinese_PRC_CI_AS 例子: SELECT A.Name FROM A ...
- Mapped Statements collection does not contain value for xxx
这是我第二次遇到的这个问题了,总结下. 第一次的问题是 mybatis的sqlSessionFactory的mapperLocations,配置的是这个路径下的所有映射文件,但是我没写的没有在该路径下 ...
- LED Keychain: Timeless Business Gift
Every business owner understands the importance of reducing marketing budgets and investing in sales ...
- [AHOI2002] 芝麻开门 - 数论
求 \(n^k\) 的因子和, \(n \leq 2^{16}, k \leq 20\) Solution \[\prod_i \frac{p_i^{q_ik+1}-1}{p_i-1}\] #incl ...
- IntelliJ WebStorm 2020最新 永久破解激活教程【全网最强,可用至2100年】
说明:都到了2020年,当然要用最新的IDE,目前最新是2019.3.1版本 ①IntelliJ WebStorm 2019.3.1安装永久破解[最强] 一. 在官网下载WebStorm安装包 链接 ...
- Mysql备份参数
--all-databases , -A 导出全部数据库. mysqldump -uroot -p --all-databases --all-tablespaces , -Y 导出全部表空间. my ...