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 ...
随机推荐
- windows和linux环境下使用google的glog日志库
一.概述 glog是google推出的一款轻量级c++开源日志框架,源码在github上,目前最新release版本是v0.3.5. githut地址:https://github.com/googl ...
- python面向对象基础-01
面向对象(OOP)基本概念 前言 话说三国时期曹军于官渡大败袁绍,酒席之间,曹操诗兴大发,吟道:喝酒唱歌,人生真爽! 众将直呼:"丞相好诗",于是命印刷工匠刻板印刷以流传天下; 待 ...
- Comet OJ - Contest #5 迫真图论 (图分块)
大意: 给定无向图, 点$i$点权$b_i$, 边$(x,y,z)$对序列贡献是把$A[b_x \oplus b_y]$加上$z$. 多组询问, 一共三种操作: 1. 修改点权. 2.修改边权. 3. ...
- hdu 6143
题意:有m种字符,要求构造两段长度为n的字符串,其中这两段不能有相同的字符 枚举左边选了i种字符,右边可以选1,2....min(n,m-i)种字符 这样就把问题转化为用k种字符构造n长度的字符串的种 ...
- Django rest-framework框架-组件之路由
路由: a. url(r'^(?P<version>[v1|v2]+)/v1/$',views.ViewView.as_view()) url(r'^(?P<version>[ ...
- springboot启动流程(十二)springboot事务自动配置
所有文章 https://www.cnblogs.com/lay2017/p/11478237.html 正文 在上一篇文章中,我们简单了解了aop的处理过程.代理增强之前,先生成Advisor,然后 ...
- class类 - extends
继承是面向对象中一个比较核心的概念.ES6 class的继承与java的继承大同小异,如果学过java的小伙伴应该很容易理解,都是通过extends关键字继承.相较于ES5当中通过原型链继承要清晰和方 ...
- .tar.gz文件和.tar.xz文件的解压和压缩
1,.tar文件 tar -cvf 压缩 tar -xvf 解压 例如: tar -xvf mysql-8.0.16-linux-glibc2.12-x86_64.tar 2,.xz文件 xz ...
- Docker部署code-server
Docker部署code-server 版本:codercom/code-server:v2 code-server可以放在服务器上,随时随地在浏览器中,编写代码.运行.调试: 手机,pad都可以进行 ...
- 解决在Linux操作系统下无法连接MySQL服务端的问题
遇到这种问题的时候我们需要考虑的是防火墙规则,因为防火墙默认是禁止所有端口访问的,所以我们需要添加一个访问端口来连接MySQL. 命令如下: 允许某端口 firewall-cmd --zone= ...