Submission

Status:

PPPPPPPPP-

Score: 90

User: solarsunny

Problemset: เลขดวง

Language: c

Time: 0.001 second

Submitted On: 2024-12-20 19:29:55

#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;



    if(d < 8 && d > 0 ) {
        if(d == 1) {
            t -= (d-1 + d-7);
        } else {
            t -= (d-7);
        }
        
    }

    if(daysinm == 30) {
        if(d >= 24 ) {
            if(d == 30) {
                t -= (d+1 + d+7);
            } else {
                t -= d-7;
            }
        }
    } else {
        if(d >= 25 ) {
            if(d == 31) {
                t -= (d+1 + d+7);
            } else {
                t -= d+7;
            }
        }
    }



    int d2 = ((d % 7) + start - 1)%7;

    if(d2 == 1) {
        t -= d-1;
    }

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

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