A. Creating a Character
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
You play your favourite game yet another time. You chose the character you didn't play before. It has strstr points of strength and intint points of intelligence. Also, at start, the character has expexp free experience points you can invest either in strength or in intelligence (by investing one point you can either raise strength by 11 or raise intelligence by 11).
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 TT (1≤T≤1001≤T≤100) — the number of queries. Next TT lines contain descriptions of queries — one per line.
This line contains three integers strstr, intint and expexp (1≤str,int≤1081≤str,int≤108, 0≤exp≤1080≤exp≤108) — the initial strength and intelligence of the character and the number of free points, respectively.
Output
Print TT integers — one per query. For each query print the number of different character builds you can create.
Example
input
Copy
4 5 3 4 2 1 0 3 5 5 4 10 6
output
Copy
3 1 2 0
Note
In the first query there are only three appropriate character builds: (str=7,int=5)(str=7,int=5), (8,4)(8,4) and (9,3)(9,3). All other builds are either too smart or don't use all free points.
In the second query there is only one possible build: (2,1)(2,1).
In the third query there are two appropriate builds: (7,6)(7,6), (8,5)(8,5).
In the fourth query all builds have too much brains.
问有多少种方式使得A>B,A=a+c1,B=b+c2,c1+c2=c。
二分出最小最小的c1使得A>B即可。
#include <algorithm>������ //STLͨ���㷨
#include <bitset>����������//STL�����
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>���������� //STL˫�˶�������
#include <exception>������ //�쳣������
#include <fstream>
#include <functional>������//STL�������㺯���������������
#include <limits>
#include <list>������������//STL���������
#include <map>������������ //STL ӳ������
#include <iomanip>
#include <ios>������������//�������룯���֧��
#include<iosfwd>����������//���룯���ϵͳʹ�õ�ǰ������
#include <iostream>
#include <istream>�������� //����������
#include <ostream>�������� //���������
#include <queue>���������� //STL��������
#include <set>������������ //STL ��������
#include <sstream>��������//�����ַ�������
#include <stack>���������� //STL��ջ������������
#include <string>����������//�ַ�����
#include <vector>����������//STL��̬��������
#define ll long long
using namespace std;
#define rep(i,a,b) for(register int i=(a);i<=(b);i++)
#define dep(i,a,b) for(register int i=(a);i>=(b);i--)
//priority_queue<int,vector<int>,less<int> >q;
int dx[]= {-1,1,0,0,-1,-1,1,1};
int dy[]= {0,0,-1,1,-1,1,1,-1};
const int maxn = 1000000+66;
const int maxm=100000+66;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f3f3f3f3fLL;
const int INF=99999999;
int main()
{
int t;
cin>>t;
while(t--)
{
int a,b,c;
cin>>a>>b>>c;
int ans=0;
int l=0,r=c+1;
int flag=0;
while(l<r)
{
int mid=(l+r)/2;
if(mid+a>c-mid+b)
{
flag=1;
r=mid;
}
else
{
l=mid+1;
}
}
if(l+a<=b)
ans=0;
else
ans=c-l+1;
cout<<ans<<endl;
}
}
本文介绍了一种算法,用于计算在给定初始属性和自由点数的情况下,创建游戏角色的不同方式数量,确保力量属性严格大于智力属性。通过二分查找确定最小的力量增加量,使力量超过智力,从而计算可能的角色构建方案。

639

被折叠的 条评论
为什么被折叠?



