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