Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: punzacp555

Problemset: เลขดวง

Language: cpp

Time: 0.004 second

Submitted On: 2026-09-25 18:02:58

#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int mxd, fst, bday;
    cin >> mxd >> fst >> bday;
 
    int a[39];
    memset(a, 0, sizeof(a));

    int d = fst-1;
    for(int i=1; i<=mxd; i++) {
        a[i] = d+1;
        d++;
        d %= 7; 
    }

    // for(int i=1; i<=mxd; i++) cout << a[i] << "  ";
    int ans = 0;
    if(a[bday-1] < 7) ans += bday-1;
    if(a[bday+1] > 1) ans += bday+1;
    if(a[bday-7] == a[bday]) ans += bday-7;
    if(a[bday+7] == a[bday]) ans += bday+7;

    cout << ans;

    return 0;
}