Luo Gu P1424 solution to a problem

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/ks_deer/article/details/102765618

# Luo Gu P1424 explanations
topic background
original questions are too simple, now improved to let the little weekend break, please redo the problem has been done.

Title Description
There is a small fish, which normally swim 250 kilometers a day, weekends (Saturday and Sunday practice), assuming that counting from the start of week x (1 \ le x \ le 7) x (1≤x≤7), over n ( the n-\ Le 10 ^ 6) the n-(n ≤ 10
6
) days later, the cumulative total fish swim many kilometers do?

Input format
input two integers x, n (counting from the circumferential represents x, after n days).

Output format
output an integer representing the number of small fish swimming cumulative kilometers.

#include <stdio.h>

int main(void)
{
    int x,n;
    int momo,day;
    scanf("%d %d", &x,&n);
    momo = (n % 7) - 1;
    if(x + momo <= 5)
    {
        day = n -(n / 7)*2;
    }
    if(x + momo == 6)
    {
         day = n- (n / 7)*2 - 1;
    }
    if(x + momo >= 7)
    {
         day = n - (n / 7)*2 - 2;
    }
    if(x == 7)
    {
        printf("%d", (day+1)*250);
    }
    else
    {
        printf("%d", day*250);
    }
    return 0;
}

Guess you like

Origin blog.csdn.net/ks_deer/article/details/102765618