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 ;
}
这是我的第一篇博客,谢谢关注。

Educational Codeforces Round 72 (Rated for Div. 2) A题的更多相关文章

  1. Educational Codeforces Round 72 (Rated for Div. 2) C题

    C. The Number Of Good Substrings Problem Description: You are given a binary string s (recall that a ...

  2. Educational Codeforces Round 72 (Rated for Div. 2) B题

    Problem Description: You are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a ...

  3. Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序

    Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] ​ 给你 ...

  4. 拓扑排序入门详解&&Educational Codeforces Round 72 (Rated for Div. 2)-----D

    https://codeforces.com/contest/1217 D:给定一个有向图,给图染色,使图中的环不只由一种颜色构成,输出每一条边的颜色 不成环的边全部用1染色 ps:最后输出需要注意, ...

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

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

  6. Coloring Edges(有向图环染色)-- Educational Codeforces Round 72 (Rated for Div. 2)

    题意:https://codeforc.es/contest/1217/problem/D 给你一个有向图,要求一个循环里不能有相同颜色的边,问你最小要几种颜色染色,怎么染色? 思路: 如果没有环,那 ...

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

  8. Educational Codeforces Round 72 (Rated for Div. 2)E(线段树,思维)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;#define BUF_SIZE 100000 ...

  9. Educational Codeforces Round 72 (Rated for Div. 2)C(暴力)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;char s[200007];int a[20 ...

随机推荐

  1. python学习-25 函数递归

    递归 例如: def abc(n): print(n) if int(n/2) == 0: return n return abc(int(n/2)) abc(10) 运行结果: 10 5 2 1 P ...

  2. Ettercap 帮助文档

    Ettercap(8)帮助 (翻译来自百度翻译,原文附于文后,个人润色) 1.概述 Ettercap-多用途嗅探器/内容过滤器,用于中间人攻击 重要提示 自Ettercap Ng(以前为0.7.0)以 ...

  3. PAT(B) 1012 数字分类(Java)

    题目链接:1012 数字分类 代码 /** * Score 20 * Run Time 142ms * @author wowpH * @version 1.1 */ import java.util ...

  4. 二、点亮LED

    接着上一章,本章来实现控制LED的亮灭操作: 一.驱动框架 #include <linux/fs.h> #include <linux/init.h> /* 定义文件内私有结构 ...

  5. c++/c在两个文件公用一个变量

    在一个cpp文件定义一个文件 在另一个文件extern+定义

  6. BZOJ3998 TJOI2015弦论(后缀自动机)

    先考虑相同子串视为一个.按SAM的拓扑序预处理出从每个节点开始能得到多少个本质不同子串(注意虽然一个节点对应多个子串,但到达该点时当前的子串显然是确定为其中一个的),然后按位贪心即可. 相同子串视为多 ...

  7. 17-MySQL DBA笔记-应用程序调优

    第17章 应用程序调优 本章将主要讲述应用程序调优的一些方法和步骤,应用程序调优的领域很广,本章主要关注的是涉及数据库方面的调优. 在进行性能分析之前,我们先要熟悉应用的角色,它是什么版本的,做什么的 ...

  8. java 框架-分布式服务框架2Dubbo

    https://blog.csdn.net/houshaolin/article/details/76408399 1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的 ...

  9. 什么是虚拟DOM

    一.前言 虚拟DOM概念随着react的诞生而诞生,由facebook提出,其卓越的性能很快得到广大开发者的认可:继react之后vue2.0也在其核心引入了虚拟DOM的概念,本文将以vue2.0使用 ...

  10. eclipse导入项目后出现红色叉号的解决方案

    对于一名程序员来说,我导入的项目在项目的名称上无端加了一个红色的叉号,虽然这个不友好的符号,对于我整个的项目运行没有任何影响,但是总让我觉得不舒服,大大的叉号写在我的项目的脑袋上,我心里能舒服吗?于是 ...