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 ...
随机推荐
- ThinkPHP 3.2 生成静态页面
1:在根目录下的全局index.php中加下面这行: define('HTML_PATH', './htm');//生成静态页面的文件位置 2:在项目的配置文件config.php中加下面这行: 'H ...
- java 寒假作业
寒假作业 现在小学的数学题目也不是那么好玩的. 看看这个寒假作业: □ + □ = □ □ - □ = □ □ × □ = □ □ ÷ □ = □ (如果显示不出来,可以参见[图1.jpg]) 每个方 ...
- POJ 3259:Wormholes bellman_ford判定负环
Wormholes Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 37906 Accepted: 13954 Descr ...
- 如何修改 app.config 的配置信息
如何修改 app.config 的配置信息 收藏 最问这个问题的人有点多,其实 .Net 提供了这样的功能我们可以在 app.config 中 userSettings 节点中保存我们的应用程序设置信 ...
- Linux系统测试工具
一.文件系统测试工具简介 1.LTP 参考网站:http://oss.sgi.com/projects/ltp/ LTP(Linux Test Project)是由SGI和IBM联合发起的项目,提供一 ...
- java#内部类和嵌套类
内容思路来自Java编程思想,个人读书做的笔记,仅个人复习之用,故他人参考请自行辨别内容是否有错误. 在类的类部可以定义类,叫做内部类.如果这个内部类被static修饰,此时内部的类叫做嵌套类. 内部 ...
- MongoDB首次启动常见问题
问题1. exception in initandlisten 29 data directory /data/db not found 问题:MongoDB默认存储路径为/data/db,这里显示没 ...
- SSM 整合配置以及一个简单登陆案例(个人记录)
SSM 文件以及大部分参考博客 https://blog.csdn.net/qq598535550/article/details/51703190 简答的登陆注册案例下载链接在末尾补贴图了 我建立的 ...
- Problem I: Ingenious Lottery Tickets
Problem I: Ingenious Lottery Tickets Your friend Superstitious Stanley is always getting himself int ...
- Codeforces 1111C Creative Snap分治+贪心
Creative Snap C. Creative Snap time limit per test 1 second memory limit per test 256 megabytes inpu ...