Submission

Status:

PPPPPPPPPP

Score: 100

User: solarsunny

Problemset: เลขดวง

Language: c

Time: 0.002 second

Submitted On: 2024-12-20 19:41:41

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

int main() {
    int daysinm;
    scanf("%d", &daysinm);
    int start;
    scanf("%d", &start);
    int d;
    scanf("%d", &d);
    //int t = d+1 + d-1 + d+7 + d-7;
    int t=0;


    if(d > 7 ) {
        t += d-7;
    }

    if(d <= daysinm-7) {
        t += d+7;
    }

    int d2 = (d + start + 5)%7 ;

    if(d > 1 && d2 != 0) {
        t += d-1;
    }

    if(d< daysinm && d2 != 6) {
        t += d+1;
    }

    printf("%d \n", t);
    return 0;
}