Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Nagornz

Problemset: เลขดวง

Language: cpp

Time: 0.003 second

Submitted On: 2025-09-21 23:11:25

#include <stdio.h>

int main(){
    int X, S, N;
    scanf("%d %d %d", &X, &S, &N);
    S--; // เนื่องจากข้อมูลนำเข้าอยู่ในรูปแบบ 1-indexed
    int col = (N + S - 1) % 7;
    int ans = 0;
    if (N > 7) ans += N - 7;
    if (N + 7 <= X) ans += N + 7;
    if (col > 0 && N > 1) ans += N - 1;
    if (col < 6 && N < X) ans += N + 1;
    printf("%d", ans);
}