Submission
Status:
P-PPP-PPP-
Subtask/Task Score:
70/100
Score: 70
User: santanaja07
Problemset: เลขดวง
Language: cpp
Time: 0.003 second
Submitted On: 2025-09-27 19:21:29
#include <bits/stdc++.h>
using namespace std;
int main() {
int mday,bday,week;
cin>>mday>>week>>bday;
int c[7][9];
for(int i=0;i<7;i++){
for(int j=0;j<9;j++){
c[i][j]=0;
}
}
bool stop=false;
for(int i=1;i<6;i++){
for(int j=1;j<8;j++){
if(c[i][j-1]==mday){
stop=true;
break;
}
if(i==1&&j==week-1){
c[i][j]=1;
}else if(i==1&&j>=week-1){
c[i][j]=c[i][j-1]+1;
}else if(i!=1&&j==1){
c[i][j]=c[i-1][7]+1;
}else if(i>1&&c[i][j-1]<mday){
c[i][j]=c[i][j-1]+1;
}
}
if(stop){
break;
}
}
/*for(int i=0;i<7;i++){
for(int j=0;j<9;j++){
cout<<c[i][j]<<" ";
}
cout<<"\n";
}*/
int sum=0;
for(int i=0;i<7;i++){
for(int j=0;j<9;j++){
if(c[i][j]==bday){
sum=c[i+1][j]+c[i-1][j]+c[i][j-1]+c[i][j+1];
}
}
}
cout<<sum;
}