跳到正文

题解

【LGR-302-Div.2】T1

gitxiaozheng约 3 分钟
原文
文章信息与版本

文章信息

发布
2026年9月25日
收录
2026年9月26日
更新
2026年11月11日
篇幅
约 3 分钟
题目
P17483

版本

  1. v1当前

很简单,模拟就行,怎么依题意模拟已经在代码里说的很明白。

本题输出结果以 0.010.01 为单位,那你把所有数乘 100100,就可以当作整数计算了,不需要 double。

AC code

代码经过后期注释。

C++
//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');
	}
}

原文