为什么我的程序只能得40分啊大佬们? #1#2#3错了
查看原帖
为什么我的程序只能得40分啊大佬们? #1#2#3错了
1038752
tongchiyue楼主2023/8/21 14:56
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	double xp=10,a,b=0,c=0,d,x=0;
	double s[20000],j[20000];
	cin >> a;
	for (int i = 0; i < a; ++i)
	{
		cin >> s[i] >> j[i];
	}
	for (int i = 0; i < a; ++i)
	{
		xp = xp - s[i];
		if (xp > 10)
		{
			xp = 10;
		}
		else
		{
			if (xp <= 0)
			{
				break;
			}
		}
		c = c + j[i];
	}
//		cout <<  j[i] << endl;
//	cout << c << endl; 
	while (c >= d)
	{
		d = pow(2,x);
//		cout << d << endl;
		b = b + 1;
//		cout << b << endl;
		c = c - d;
		x = x + 1;
	}
	cout << b << " " << c;
	return 0;
}
2023/8/21 14:56
加载中...