社区讨论
2-5测试点RE求调
P9797 [NERC 2018] Guest Student参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @locbq2z0
- 此快照首次捕获于
- 2023/10/30 11:11 2 年前
- 此快照最后确认于
- 2023/11/02 10:43 2 年前
自己组的测试点基本都能过,但是不知道为什么会出现RE,我觉得也没出现RE的条件啊,求大佬调一下
CPP#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;
}
回复
共 2 条回复,欢迎继续交流。
正在加载回复...