A. Yet Another String Game
题目传送门:
水题
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
string str;
cin>>str;
for(int i=0;i<str.length();i++)
{
if(i%2==0)
{
if(str[i]!='a') printf("a");
else printf("b");
}
else
{
if(str[i]!='z') printf("z");
else printf("y");
}
}
printf("\n");
}
//system("pause");
return 0;
}
B. The Great Hero
题目传送门:
题目大意:
hero有A点攻击力和B点血量。有n只怪兽,每只怪兽有ai点攻击力和bi点血量。问hero能不能杀死所有怪兽,即使在杀完最后一只怪兽时死完。
思路:
其实这题可以写的非常的简单。
我们可以想到当能杀死怪兽时而又最惨烈的情况那就是hero用最后一滴血,杀死了攻击力最高的怪兽。也就是B - 1 + maxn >= sum (maxn为怪兽的最高攻击力,sum为杀死所有怪兽需要承受的攻击)
AC Code
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e5+10;
LL a[N],b[N];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
LL p,q;
int n;
LL maxn=0;
scanf("%lld%lld%d",&p,&q,&n);
for(int i=1;i<=n;i