为什么只有60分,求助大佬
查看原帖
为什么只有60分,求助大佬
78984
achdu0000楼主2020/11/27 15:44

话不多说,直接上代码,求求大佬,救救孩子吧

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	int day[1001], n,prize=0;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> day[i];
	int card = 0, uncard = 0,jian;
	for (int i = 1; i <= n; i++)
	{
		if (uncard)
		{
			jian = pow(2, uncard - 1);
			if (jian >= card)card = 0;
			else
				card -= jian;
		}
		if (!day[i])uncard++;
		else
		{
			card++;
			if (card == 1 || card == 2)prize++;
			if (card >= 3 && card <= 6)prize += 2;
			if (card >= 7 && card <= 29)prize += 3;
			if (card >= 30 && card <= 119)prize += 4;
			if (card >= 120 && card <= 364)prize += 5;
			if (card >= 365)prize += 6;
			uncard = 0;
		}
	}
	cout << prize << endl;
	return 0;
}

2020/11/27 15:44
加载中...