Problem Description:

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≤108, 0≤exp≤108) — the initial strength and intelligence of the character and the number of free points, respectively.

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

input


output


题意:分配exp点经验给力量s和智力i,求有多少种分配情况使s比i高。

思路:分类讨论,模拟实现

以下是又臭又长的AC代码:

 #include<bits/stdc++.h>

 using namespace std;
#define int long long signed main(){
int _;
cin>>_;
while(_--){
int a,b,c;
scanf("%lld%lld%lld",&a,&b,&c);
if(c==){
if(a>b){
printf("1\n");
}else{
printf("0\n");
}
continue;
}
if(a+c<=b){
printf("0\n");continue;
}
if(b+c<a) {
printf("%lld\n",c+);continue;
}
if(a>b){
int sum=a+b+c;
if(sum%==){
int ans=a+c-sum/;
printf("%lld\n",ans);
} else{
int ans=a+c-sum/;
printf("%lld\n",ans);
}
continue;
}
if(a==b){
if(c%)
c++;
printf("%lld\n",c/);
continue;
}
if(a<b){
int temp=b-a;
c-=temp;
if(c%)
c++;
printf("%lld\n",c/);
continue;
}
}
return ;
}
这是我的第一篇博客,谢谢关注。

最新文章

  1. Scala 的确棒
  2. Coding源码学习第二部分(FunctionIntroManager.m)
  3. Linux网络编程系列-TCP传输控制
  4. Android 学习笔记 BroadcastReceiver广播...
  5. abs()函数的返回值问题
  6. Android学习笔记03-搭建Win8下的Android开发环境
  7. Java多线程-工具篇-BlockingQueue
  8. Android 再按一次退出程序
  9. 四、C#方法和参数
  10. Oracle select into from 和 insert into select
  11. BZOJ 1691: [Usaco2007 Dec]挑剔的美食家( 平衡树 )
  12. 性能测试之LoardRunner 结果分析
  13. 怎样处理iOS 5与iOS 6的 low-memory
  14. SQL SERVER大话存储结构(4)_复合索引与包含索引
  15. java学习笔记之StringBuilder
  16. 03 EditText文本编辑框
  17. jquery .map() 和 .each()函数结合使用
  18. expect交互式安装软件
  19. 初探 Yii2 的测试模式 index-test.php
  20. Java实现WordCount

热门文章

  1. List 集合的常用方法总结
  2. freemarker循环、下标及判断
  3. Go part 4 数据容器(数组,slice,string,map,syncMap,list)
  4. 微信支付之二维码支付(native)
  5. MySql Host is blocked because of many connection errors 问题的解决方法
  6. nginx的so_keepalive和timeout相关小计
  7. springboot系列(三) 启动类中关键注解作用解析
  8. Java基于Redis的分布式锁
  9. jeffy-vim-v2.9
  10. 自定义printf 打印函数