当前位置: 代码迷 >> 综合 >> 枚举训练:G题 Guest Student
  详细解决方案

枚举训练:G题 Guest Student

热度:44   发布时间:2024-01-13 17:03:31.0

题目来源

一篇题解

#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;
}
  相关解决方案