Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Kei

Problemset: เลขดวง

Language: cpp

Time: 0.003 second

Submitted On: 2026-10-07 16:06:58

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

void solve(){
    int nmo,first,bd,thesum=0;
    //sun to S    
    cin>>nmo>>first>>bd;
    //+1-1 +7-7;
    //find septenary
    int septen = (first+bd-1)%7;
    if(bd==nmo ? thesum+=bd-1 : thesum+=(2*bd));
    if(septen == 1) thesum=thesum-bd+1;
    else if(septen==0 && bd!=nmo) thesum=thesum-bd-1;
    if(bd+7>nmo ? thesum+=bd-7 : (bd<=7 ? thesum+=bd+7 : thesum+=(2*bd)));
    cout << thesum;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}