【LGR-302-Div.2】T1
gitxiaozheng · · 题解
很简单,模拟就行,怎么依题意模拟已经在代码里说的很明白。
本题输出结果以 double。
::::success[AC code] 代码经过后期注释。
//edit by devc++
//by gitxiaozheng/dakada
#include<bits/stdc++.h>
using namespace std;
#define L long long
#define iotype L //zigai
#define space putchar(' ')
#define enter putchar('\n')
inline iotype qcin();
void qcout(iotype);
int main(){
//Your code is here...
for(int T=qcin();T;T--){
int n=qcin();
L pw=100;
for(int i=0;i<n;i++){
L x=qcin(),y=qcin();
pw-=min(x,50ll);//由于反复尝试造成的火力损失最多为 0.5。即中弹次数超过 50 次后将不再减少火力。
pw=max(100ll,pw);//如果某次操作使火力低于 1.00,则会立即修正为 1.00
pw+=y;//主角获得了 y 个 P 点,每个 P 点使火力增加 0.01。
pw=min(400ll,pw);//如果某次操作使火力高于 4.00,则会立即修正为 4.00。
}
qcout(pw);
enter;
}
return 0;
}
inline iotype qcin(){
iotype k=0,f=1;
char c=getchar();
while(c<'0'||c>'9'){
if(c=='-'){
f=-1;
}
c=getchar();
}
while(c>='0'&&c<='9'){
k=k*10+c-'0';
c=getchar();
}
return k*f;
}
void qcout(iotype x){
static int num[20];
int tot=0;
if(x<0){
putchar('-');
x=-x;
}
while(x>=10){
num[++tot]=x%10;
x/=10;
}
putchar(x+'0');
for(int i=tot;i>=1;i--){
putchar(num[i]+'0');
}
}
::::