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 ...
随机推荐
- JAVA虚拟机:对象的创建
在虚拟机中,当遇到需要new一个对象时,虚拟机首先会去处于方法区的常量池中查找new指令的参数,即查找此类的符号引用是否已存在,并且检查此符号引用的代表类是否已经做过加载.解析和初始化,如果做过则不会 ...
- gym 101911
A. Coffee Break 题意:每天有m小时,你喝咖啡需要花一小时,你想在n个时刻都喝过一次咖啡,老板规定连续喝咖啡的间隔必须是d以上,求最少需要多少天才能喝够n次咖啡,并输出每个时刻第几天喝. ...
- Program-Language
1. 主流编程语言 2. 编程语言分类 2.1 编译or解释 2.2 按照客观系统的描述可分为两类 2.3 按照编程范型可分为 3. 语言范式 Paradigm 4. 计算机语 ...
- 连接mysql报错java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized...解决方法
报错内容: java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or represents mo ...
- ionic实现滑动的三种方式
在移动端受屏幕大小所限,展示内容很多的时候,就要使部分区域进行滑动.本文展示项目中所有到的几种方式,大家可以看自己的需求选择合适的滑动方式.实现滑动的基本原理,有两个容器A.B,假如A在外层,B在内层 ...
- 文献阅读报告 - Social BiGAT + Cycle GAN
原文文献 Social BiGAT : Kosaraju V, Sadeghian A, Martín-Martín R, et al. Social-BiGAT: Multimodal Trajec ...
- Web application architecture overview
- yolov3输出检测图片位置信息
前言 我们在进行图片识别后需要进行进一步的处理,该文章会介绍:1.怎样取消lables;2.输出并保存(.txt)标记框的位置信息 一.去掉label 在darknet/src/image.c 收索d ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-remove
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-heart
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...