https://codeforces.com/contest/1163/problem/A

题解:

C++版本一

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int a[N];
char str;
struct node{};
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d%d",&n,&m);int l=n/2;if(m==0){cout<<1<<endl;}else if(m<=l){cout<<m<<endl;}else if(n%2&&m==l+1){cout<<n/2<<endl;}else if(n%2){cout<<n/2-(m-1-l)<<endl;}else{cout<<n/2-(m-l)<<endl;}//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}

C++版本二

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int a[N];
char str;
struct node{};
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d%d",&n,&m);cout<<min(n-m,max(m,1))<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}

Eating Soup相关推荐

  1. 水题Eating Soup

    A. Eating Soup time limit per test1 second memory limit per test256 megabytes inputstandard input ou ...

  2. Codeforces 1163A - Eating Soup

    题目链接:http://codeforces.com/problemset/problem/1163/A 题意:n 只猫围成一圈,离开 m 只,最多剩下几组猫. 思路:当 n == m 即猫都离开时 ...

  3. 行家来信 | 我在国际AI开源组织LFAI当董事的200天

    来信行家:肖涵 腾讯AI Lab高级科学家 量子位 出品 | 公众号 QbitAI 编者按:在国际知名开源组织工作是一种怎样的体验?目前中国组织和公司,正在越来也多参与到全球技术开源的生态建设中,口碑 ...

  4. soup.a.parents都有哪些

    代码: import requests from bs4 import BeautifulSoup r = requests.get("https://python123.io/ws/dem ...

  5. Python Beautiful Soup类的基本元素

    Beautiful Soup库是解析,遍历,维护"标签树"的功能库. 条件: pip install lxml pip install html5lib 以下5种基本元素是使用方法 ...

  6. Python爬虫利器之Beautiful Soup的用法,以及实例!

    可以利用 pip 来安装: pip install beautifulsoup4 源代码: import requests r = requests.get("https://python1 ...

  7. Python爬虫利器之Beautiful Soup的全世界最强用法 五百行文章!

    0. 前言 爬虫是一个非常有意思的东西,比如自己做的一个网页上面什么数据都没有就可以爬虫别人的 然后进行去重 数据分析等等 在这里因为爬虫涉及到的方面非常多 1. Beautiful Soup的简介 ...

  8. lxml安装_Beautiful Soup的安装和使用

    不用正则也可匹配html语言,代替正则解析html的这个工具叫做Beautiful Soup(美味的汤?哈哈哈哈哈哈哈) 安装Beautiful Soup Pip install Beautiful ...

  9. python爬虫beautifulsoup实例-Python爬虫学习(二)使用Beautiful Soup库

    (一)使用Beautiful Soup库(默认将HTML转换为utf-8编码) 1,安装Beautiful Soup库:pip install beautifulsoup4 2,简单使用: impor ...

最新文章

  1. Spring Cloud Alibaba基础教程:Nacos的数据持久化
  2. MFC 基础知识:主对话框与子对话框(二)
  3. mysql无法导入函数和存储过程解决方法
  4. maven项目不编译xml文件
  5. 特朗普前竞选经理犯罪证据曝光,竟是因不会 PDF 转换!
  6. Windows 未能启动。原因可能是最近更改了硬件或软件。解决此问题的步骤
  7. Centos6.x 64位 安装JDK
  8. DLL系列6.函数转发器
  9. 自然语言处理——基于预训练模型的方法——第2章 自然语言处理基础
  10. Rayman的绝顶之路——Leetcode每日一题打卡12
  11. 蓝桥杯每日一练----字符串逆序
  12. 扩展名是.ps的PostScript文件详解
  13. 使用这5款模拟器访问备选操作系统
  14. springcloud 加入spring session通过zuul请求session不一致问题
  15. 密码学数学基础——群、环、域
  16. How to deal with Imbalanced Datasets in PyTorch - Weighted Random Sampler Tutorial
  17. 物联网之STM32开发一(基础知识)
  18. 信息学奥赛一本通-1047
  19. 穷游第13国之韩国囧途之旅
  20. twilio给自己发短信

热门文章

  1. 安卓虚拟linux系统教程,在Linux上模拟Android应用程序的3种方法 | MOS86
  2. java写龟兔赛跑_简单的实现java多线程——龟兔赛跑
  3. 怎么在linux指定目录下查找文件夹下,Linux下如何使用find命令指定目录查找文件...
  4. linux pro*c环境配置,打造ubuntu下精简版的oracle客户端及pro*c编译环境
  5. csp2020 j2民间数据下载_华为麒麟 990 5G 下载速率领先
  6. java调用第三方dll文件 源码_C++调用python文件(包含第三方库)
  7. 计算机系统层次中应用语言级,计算机系统的多级层次结构
  8. 四十七、Tableau地理可视化
  9. R中方差,协方差,相关系数
  10. 直播丨BMMeetup第2期:大模型计算加速技术,2场特邀和7位青年学者技术报告联袂上演...