You play your favourite game yet another time. You chose the character you didn't play before. It has str points of strength and int points of intelligence. Also, at start, the character has exp free experience points you can invest either in strength or in intelligence (by investing one point you can either raise strength by 1 or raise intelligence by 1).

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.

Input

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.

Output

Print TT integers — one per query. For each query print the number of different character builds you can create.

Example
input
4
5 3 4
2 1 0
3 5 5
4 10 6
output
3
1
2
0
Note

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的更多相关文章

  1. 《Note --- Unreal 4 --- behavior tree》

    Web: https://docs.unrealengine.com/latest/INT/Engine/AI/BehaviorTrees/index.html Test project: D:\En ...

  2. NSCharacter​Set在字符串操作中得使用

    NSCharacterSet以及它的可变版本NSMutableCharacterSet,用面向对象的方式表示一组Unicode字符,它经常与NSString及NSScanner组合起来使用,在不同的字 ...

  3. Educational Codeforces Round 72 (Rated for Div. 2)

    https://www.cnblogs.com/31415926535x/p/11601964.html 这场只做了前四道,,感觉学到的东西也很多,,最后两道数据结构的题没有补... A. Creat ...

  4. Educational Codeforces Round 72

    目录 Contest Info Solutions A. Creating a Character B. Zmei Gorynich C. The Number Of Good Substrings ...

  5. 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 ...

  6. Pointcut is not well-formed: expecting 'identifier' at character position 0

    异常如下: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDa ...

  7. ln: creating hard link 问题

    其实很简单: chattr -R -i xxxxx           #xxxxx为你需要修改的文件,这样就可以了... 下面全不是重点,扯淡.... ln: creating hard link ...

  8. Creating an API-Centric Web Application[转]

    Creating an API-Centric Web Application 转自 http://hub.tutsplus.com/tutorials/creating-an-api-centric ...

  9. 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  ...

随机推荐

  1. LoadRunner回放脚本时,显示浏览器的设置

    打开LoadRunner的VuGen,选择Tools-->General Options-->Display,在Display里将 Show browser during replay打钩 ...

  2. 热门提示输入之AutoCompleteTextView

    前言: 在我们百度时,经常会遇到在你输入一个内容后在你的输入框的下面会提示一些别的热门的东西,接下来我们来简单实现这种功能 正文: 直接上代码,和之前的东西都大同小异 下面是Java代码 public ...

  3. PE文件中找导出表

    导出表: typedef struct _IMAGE_EXPORT_DIRECTORY { DWORD Characteristics; // 未使用,总为0 DWORD TimeDateStamp; ...

  4. 阿里云安装mysql,初始化密码修改

    阿里云服务器,centos7, rpm包安装MySQL,初始化了个奇葩密码 登陆不上, 修改配置文件/etc/my.cnf,在[mysqld]下面添加一行代码:skip-grant-tables se ...

  5. mac flutter 创建过程及遇到的问题

    参考: 1.入门: 在macOS上搭建Flutter开发环境 系统要求 2.mac配置环境变量 1.打开终端 2.clone flutter 命令: git clone -b beta https:/ ...

  6. 基于RabbitMQ的MQTT协议及应用

    MQTT的开源代码地址先贴在这里:https://github.com/mqtt/mqtt.github.io/wiki/servers MQTT定义: MQTT(Message Queuing Te ...

  7. R 读取回归模型的信息

    参考博客: http://blog.sina.com.cn/s/blog_8f5b2a2e0101fmiq.html https://blog.csdn.net/huangyouyu523/artic ...

  8. JAVA笔记01 变量的取名

    第2章 有意义的命名2.1 介绍2.2 名副其实 变量名太随意,haha.list1.ok 这些都没啥意义2.3 避免误导 包含List等关键字.字母o与数字0等2.4 做有意义的区分 反面教材,变量 ...

  9. P1044 火星数字

    P1044 火星数字 转跳点:

  10. (转)解决windows解决windows 7 部分程序图标显示不正常的问题

    刚解决计算机的管理选项打开出现问题,又发现系统里部分程序的快捷图标显示不出了, 曾在xp里也出现过同样的问题,常理推断,如果系统没有被病毒破坏那可能就是系统图标缓存出现问题 因此,双管齐下,一边检查系 ...