Skip to content

14022: 【原4022】FZ泛舟

题目

题目描述

author: SupremeT 原OJ链接:https://acm.sjtu.edu.cn/OnlineJudge-old/problem/4022

Description

有一天FZ在思源湖上泛舟,他上午泛舟150公里,下午泛舟100公里,晚上和周末都休息(实行双休日),假设从周x(1<=x<=7)开始算起,请问这样过了n天以后,FZ一共累计泛舟了多少公里呢?

Input Format

输入两个整数x,n(表示从周x算起,经过n天,n在long int范围内)。

Output Format

输出一个整数,表示FZ累计泛舟了多少公里。

Sample Input

3 10

Sample Output

2000

FineArtz's solution

/* FZ泛舟 */
#include <iostream>
using namespace std;

int main(){
    int x, n;
    cin >> x >> n;
    int p = n / 7 * 5;
    n %= 7;
    for (int i = x; i <= x + n - 1; ++i){
        if ((i % 6 == 0) || (i % 7 == 0)) continue;
        ++p;
    }
    cout << p * 250 << endl;
    return 0;
}

ligongzzz's solution

#include "iostream"
#include "cstdio"
using namespace std;

int main() {
    long long x, n;
    cin >> x >> n;

    long long ans = 0;
    ans += n / 7 * (250 * 5);

    for (long long i = 0; i < n % 7; ++i) {
        if (x + i != 6 && x + i != 7)
            ans += 250;
    }

    cout << ans;

    return 0;
}

skyzh's solution

#include <iostream>
using namespace std;

long long result(long long day) {
    long long sum = (day / 7) * 250 * 5;
    int x = day % 7;
    if (x >= 5) x = 5;
    return sum + x * 250;
}
int main() {
    long long x, n;
    long long sum = 0;
    cin >> x >> n;
    cout << result(x + n - 1) - result(x - 1) << endl;
    return 0;
}