大佬求助一下,本蒟蒻#2,#3,#5不过
查看原帖
大佬求助一下,本蒟蒻#2,#3,#5不过
776355
chrisxu1楼主2024/2/26 21:22

这个代码只有40分,各位大佬帮忙调一下

#include<iostream>
#include<iomanip>
#include<string>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<queue>
#define ll long long
#define ull unsigned long long
using namespace std;
ll n, grade, experience, bf;
double pop, life = 10;
int main(){
	//freopen("fraction.in","r",stdin);
	//freopen("fraction.out","w",stdout);
	cin >> n;
	while(n --){
		cin >> pop >> experience;
		if(life > 10){
			life = 10;
		}
		life -= pop;
		if(life <= 0){
			experience = bf;
			break;
		}
		while(true){
			if(experience >= (int)pow(2, grade)){
				experience -= (int)pow(2, grade);
				grade ++;
			} else {
				bf = experience;
				break;
			}
		}
    }
    cout << grade << " " << experience;
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}
/*
15
1 5
1 90
-1 7
1 478
-1 45479
-99 4543
1 0
1 0
1 0
1 0
1 0
1 0
-9 8
90 2
8 9

15 17843
*/
2024/2/26 21:22
加载中...