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 ...
随机推荐
- OOP_面向对象程序设计概述
李际军老师"面向对象程序设计"课程第一课笔记整理 面向对象程序设计概述 20世纪90年代以来面向对象程序设计(Object Oriented Programming, 简称OOP) ...
- PHP替换HTML文件中所有a标签的HREF属性,其他不变
转载出处:http://www.luanxin.top/index.php/archives/21/ 仿站的时候扒下来的代码a链接总是指向别的地方,要一个一个改的话都要累死了,展示的时候随便点一下就乱 ...
- pandas数据结构之Panel笔记
Panel创建的是三维的表 items:坐标轴0,索引对应的元素是一个DataFrame major_axis:坐标轴1,DataFrame里的行标签 minor_axis:坐标轴2,DataFram ...
- scratch少儿编程——03、动作:运动的开始,游戏的基础。
各位小伙伴大家好: 从这一期开始我们来学Scratch的具体操作. 第一季我们会从每一个脚本模块开始.一个程序块一个程序块去操作,感受它的效果. 今天我们来一起学习程序区的脚本类动作模块的指令. 动作 ...
- asp.net core-3.应用程序部署到iis
asp.net core在部署到iis 上的时候,iis服务器要装一个AspNetCoreModule,网站—>模块 具体下载地址可以去网上搜索https://www.nuget.org/pa ...
- jvm垃圾回收器介绍
上篇文章中我们讨论了jvm的内存区域,这篇文章我们来讨论针对的内存区域的垃圾回收机制. 其实针对垃圾回收我们通常考虑三个问题:1.哪些内存需要回收?2.什么时候回收?3.如何回收?下面我们针对这三个问 ...
- Visual Studio 最新插件
Resharper 最新版本下载 https://www.jetbrains.com/resharper/ 破解方法 安装完成后,打开vs 弹出注册窗口选择Activate>License S ...
- Xamarin(Android)制作启动画面
1.将启动图片保存到Drawable文件夹下 2.在Drawable文件夹下创建splashscreen.xml <?xml version="1.0" encoding=& ...
- [学习笔记]pb_ds库
前言 其实我很早开始就用pb_ds库了,用起来确实方便.但最近感觉还是对这个了解颇少,还是来补一下 话说有人会忘记头文件,其实这有个伎俩,找到电脑上的g++文件夹.Ubuntu应该在etc中,Wind ...
- JVM学习笔记——字节码指令
JVM学习笔记——字节码指令 字节码 0与 1是计算机仅能识别的信号,经过0和1的不同组合产生了数字之上的操作.另外,通过不同的组合亦产生了各种字符.同样,可以通过不同的组合产生不同的机器指令.在不同 ...