Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Patn01Z
Problemset: เลขดวง
Language: cpp
Time: 0.004 second
Submitted On: 2026-09-28 15:53:43
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int m,s,d,r,w,wm;
cin >> m >> s >> d;
r=d-8+s;
wm=2+(m-8+s)/7;
if(r<1){
w=1;
r=7+r;
}
else{w =2+r/7;}
bool right=true;
int dr=0;
bool left=true;
int dl=0;
int dt=d-7;
int db=d+7;
if((r%7==0)||(d==m)){right=false;}
if((r%7==1)||(d==0)){left=false;}
if(dt<0){dt=0;}
if(db>m){db=0;}
if(left==true){dl=d-1;}
if(right==true){dr=d+1;}
cout << (dt+db+dl+dr);
}