CF1217A Creating a Character
Since you'd like to make some fun you want to create a jock character, so it has more strength than intelligence points (resulting strength is strictly greater than the resulting intelligence).
Calculate the number of different character builds you can create (for the purpose of replayability) if you must invest all free points. Two character builds are different if their strength and/or intellect are different.
The first line contains the single integer T (1≤T≤100) — the number of queries. Next T lines contain descriptions of queries — one per line.
This line contains three integers str, int and exp (1≤str,int≤10^8,0≤exp≤10^8) — the initial strength and intelligence of the character and the number of free points, respectively.
Print TT integers — one per query. For each query print the number of different character builds you can create.
4
5 3 4
2 1 0
3 5 5
4 10 6
3
1
2
0
In the first query there are only three appropriate character builds: (str=7,int=5), (8,4) and (9,3). All other builds are either too smart or don't use all free points.
In the second query there is only one possible build: (2,1).
In the third query there are two appropriate builds: (7,6), (8,5).
In the fourth query all builds have too much brains.
先解释下题意:给定T行输入,每行输入三个整数str,int,exp。每点exp可以增加一点str或int,求str>int的方案共有多少种。
显然我们只要求出最少要加几点str使str>int就可以求出答案了。
下面给出代码,这里是用二分来求解。
#include <bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
cin>>a>>b>>c;
int l=0,r=c;
while(l<=r)
{
int mid=(l+r)/2;
if(a+mid>b+c-mid)
{
r=mid-1;
}
else
{
l=mid+1;
}
}
cout<<c-l+1<<endl;
}
return 0;
}
CF1217A Creating a Character的更多相关文章
- 《Note --- Unreal 4 --- behavior tree》
Web: https://docs.unrealengine.com/latest/INT/Engine/AI/BehaviorTrees/index.html Test project: D:\En ...
- NSCharacterSet在字符串操作中得使用
NSCharacterSet以及它的可变版本NSMutableCharacterSet,用面向对象的方式表示一组Unicode字符,它经常与NSString及NSScanner组合起来使用,在不同的字 ...
- Educational Codeforces Round 72 (Rated for Div. 2)
https://www.cnblogs.com/31415926535x/p/11601964.html 这场只做了前四道,,感觉学到的东西也很多,,最后两道数据结构的题没有补... A. Creat ...
- Educational Codeforces Round 72
目录 Contest Info Solutions A. Creating a Character B. Zmei Gorynich C. The Number Of Good Substrings ...
- Educational Codeforces Round 72 (Rated for Div. 2) Solution
传送门 A. Creating a Character 设读入的数据分别为 $a,b,c$ 对于一种合法的分配,设分了 $x$ 给 $a$ 那么有 $a+x>b+(c-x)$,整理得到 $x&g ...
- Pointcut is not well-formed: expecting 'identifier' at character position 0
异常如下: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDa ...
- ln: creating hard link 问题
其实很简单: chattr -R -i xxxxx #xxxxx为你需要修改的文件,这样就可以了... 下面全不是重点,扯淡.... ln: creating hard link ...
- Creating an API-Centric Web Application[转]
Creating an API-Centric Web Application 转自 http://hub.tutsplus.com/tutorials/creating-an-api-centric ...
- Creating Your Own Server: The Socket API, Part 1
转:http://www.linuxforu.com/2011/08/creating-your-own-server-the-socket-api-part-1/ By Pankaj Tanwar ...
随机推荐
- C语言常用函数
一.数学函数 调用数学函数时,要求在源文件中包下以下命令行: #include <math.h> 函数原型说明 功能 返回值 说明 int abs( int x) 求整数x的绝对值 计算结 ...
- Tomcat删除时问题——eclipse部署tomcat时弹出Resource'/Servers' does not exist
如果你删除一个项目的Servers文件,或者相应文件损坏等,会出现错误, Resource '/Servers' does not exist 那么就需要把它在控制台出的Servers下所部署的Tom ...
- 0104 gradle入门
背景 gradle的官网是 www.gradle.org,标题介绍是: accelerate developer productivity,翻译过来:提高开发者的生产率: 简要介绍:从手机app到微服 ...
- Ceph 概念理解
简介 Ceph是一个可靠地.自动重均衡.自动恢复的分布式存储系统,根据场景划分可以将Ceph分为三大块,分别是对象存储.块设备存储和文件系统服务. 在虚拟化领域里,比较常用到的是Ceph的块设备存储, ...
- [题解] LuoguP2764 最小路径覆盖问题
传送门 好久没做网络流方面的题发现自己啥都不会了qwq 题意:给一张有向图,让你用最少的简单路径覆盖所有的点. 考虑这样一个东西,刚开始,我们有\(n\)条路径,每条路径就是单一的一个点,那么我们的目 ...
- NO5 grep-head-tail命令
·*****grep:#过滤需要的内容(linux三剑客). -v:排除内容.eg:grep -v oldboy test.txt ·head: #头,头部.读取文 ...
- servlet3.0的文件上传代码配置怎么写
之前学习过xml配置servlet3.0的文件上传,但是变成code方式一直不知道怎么弄,相比较起来apache的文件上传配置和xml倒是没什么太大区别. 直接上代码:无需依赖,只要一个方法就好了cu ...
- Js获取页面地址参数
var url = window.location.href; //获取当前窗口的Url; 结果:http://localhost:61768/Home/Index?id=2&age=18 v ...
- Golang的基础数据类型-整型
Golang的基础数据类型-整型 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.整型概述 Go语言的整数类型一共有10个. int: 默认是有符号(signed)整形,占用空间 ...
- uni-app开发小程序-使用uni.switchTab跳转后页面不刷新的问题
uni.switchTab({ url: '/pages/discover/discover', success: function(e) { var page = getCurrentPages() ...