Educational Codeforces Round 72 (Rated for Div. 2) A题
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题的更多相关文章
- 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 ...
- Educational Codeforces Round 72 (Rated for Div. 2) B题
Problem Description: You are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a ...
- Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序
Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] 给你 ...
- 拓扑排序入门详解&&Educational Codeforces Round 72 (Rated for Div. 2)-----D
https://codeforces.com/contest/1217 D:给定一个有向图,给图染色,使图中的环不只由一种颜色构成,输出每一条边的颜色 不成环的边全部用1染色 ps:最后输出需要注意, ...
- Educational Codeforces Round 72 (Rated for Div. 2)
https://www.cnblogs.com/31415926535x/p/11601964.html 这场只做了前四道,,感觉学到的东西也很多,,最后两道数据结构的题没有补... A. Creat ...
- Coloring Edges(有向图环染色)-- Educational Codeforces Round 72 (Rated for Div. 2)
题意:https://codeforc.es/contest/1217/problem/D 给你一个有向图,要求一个循环里不能有相同颜色的边,问你最小要几种颜色染色,怎么染色? 思路: 如果没有环,那 ...
- 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 ...
- Educational Codeforces Round 72 (Rated for Div. 2)E(线段树,思维)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;#define BUF_SIZE 100000 ...
- 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 ...
随机推荐
- I2C读写EEPROM—EEPROM简介
EEPROM 是一种掉电后数据不丢失的存储器,常用来存储一些配置信息,以便系统重新上电的时候加载之.EEPOM 芯片最常用的通讯方式就是 I 2C 协议,本小节以 EEPROM 的读写实验为大家讲解如 ...
- //统计报表-供水量统计主列表分页查询 Element-ui的分页插件
<!-- //分页 --> <div class="pagination">时间(月) <el-pagination @current-change= ...
- Jfinal初次尝试及Jetty使用相关问题
Jetty介绍 Jetty官网:http://www.eclipse.org/jetty/ 参考:Jetty使用教程(一)--开始使用Jetty 1. 使用 参考上面文档,但是有些更新: echo $ ...
- 虚拟机Vmware使用记录
一直使用的是docker for windows,但是总会出现能打包,能打tag,但是push超时,所以想着弄个虚拟机来实现. 第一步: 安装VMware,安装一个ubantu最新的系统. 第二步: ...
- ...:ES6中扩展运算符(spread)和剩余运算符(rest)详解
1.扩展运算符(spread) demo1:传递数据代替多个字符串的形式 let test= function(a,b,c){ console.log(a); console.log(b); cons ...
- 利用Filter和HttpServletRequestWrapper实现请求体中token校验
先说一下项目的背景,系统传参为json格式,token为其中一个必传参数,此时如果在过滤器中直接读取request,则后续controller中通过RequestBody注解封装请求参数是会报stre ...
- Tomcat 和web 服务器配置
mkdir /usr/local/tomcat # cd /usr/local/tomcat # tar -zxvf /software/apache-tomcat-7.0.54.tar.gz 生成链 ...
- sql根据一个表查询的数据作为条件查询另一个表
代码格式如下: ) 要注意的是:in后面的查询语句必须是查询一个字段跟前面的表相对应的.比如要根据订单号orderID,OpenBills 这个表就需要查询到orderID这个字段,BillConsu ...
- 最全排序算法原理解析、java代码实现以及总结归纳
算法分类 十种常见排序算法可以分为两大类: 非线性时间比较类排序:通过比较来决定元素间的相对次序,由于其时间复杂度不能突破O(nlogn),因此称为非线性时间比较类排序. 线性时间非比较类排序:不通过 ...
- mongodb聚合查询-aggregate
Mongodb-aggregate 在工作中经常遇到一些mongodb的聚合操作,和mysql对比起来,mongo存储的可以是复杂的类型,比如数组,字典等mysql不善于处理的文档型结构,但是mong ...