题目来源
一篇题解
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define MAX_N 100007
typedef long long ll;
using namespace std;
ll ans[15];
int main() {
ll times;ll days;cin >> times;while (times--) {
ll T=0;cin >> days;for (int i = 1; i <= 7; i++) {
scanf("%lld", &ans[i]);ans[i + 7] = ans[i];T += ans[i];}ll res = 1e10;for (int i = 1; i <= 7; i++) {
ll n = days;for (int j = i; j < i + 7; j++) {
n -= ans[j];if (n % T == 0) {
res = min(res, j-i+1+n/T*7);//j-i+1代表的是由i到j的距离}}}printf("%lld\n", res);}return 0;
}