2-5测试点RE求调
查看原帖
2-5测试点RE求调
990881
VOLCANOHERE楼主2023/10/30 11:11

自己组的测试点基本都能过,但是不知道为什么会出现RE,我觉得也没出现RE的条件啊,求大佬调一下

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, total;
int arr[8];
bool judge;
void getin() {
	cin >> n;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	getin();
	while (n--){
		cin >> total;
		int beginday = 0;
		int endday = 0;
		bool judgebeginday = false;
		int lessonday = 0;
		int week = 0;
		for (int i = 1; i <= 7; i++) {
			cin >> arr[i];
			if (arr[i] == 1) {
				if (judgebeginday == false) {
					beginday = i;
					judgebeginday = true;
				}
				lessonday++;
			}
		}
		if (total % lessonday == 0) {//确定week
			week = total / lessonday - 1;//需要经过多少个满的week
		}
		else {
			week = total / lessonday;
		}
		if (week == 0) {//只有一周
			int nowday = 1;
			while (total > 0) {
				if (arr[nowday] == 1) {//可以上课
					endday = nowday;
					total--;
				}
				nowday++;
			}
			cout << endday - beginday + 1 << endl;
		}
		else {
			int nowday = beginday;
			int sum = 0;
			total -= lessonday * week;
			while (total > 0) {
				if (arr[nowday] == 1) {
					nowday++;
					sum++;
					total--;
				}
				nowday++;
			}
			cout << 7 * week + sum << endl;
		}
	}

	return 0;
}

2023/10/30 11:11
加载中...