Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: santanaja07

Problemset: เลขดวง

Language: cpp

Time: 0.004 second

Submitted On: 2025-09-27 19:28:03

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

int main() {
	int mday,bday,week;
	cin>>mday>>week>>bday;
	int c[8][9];
	for(int i=0;i<8;i++){
		for(int j=0;j<9;j++){
			c[i][j]=0;
		}
	}
	bool stop=false;
	for(int i=1;i<7;i++){
		for(int j=1;j<8;j++){
			if(c[i][j-1]==mday){
				stop=true;
				break;
			}
			if(i==1&&j==week){
				c[i][j]=1;
			}else if(i==1&&j>=week){
				c[i][j]=c[i][j-1]+1;
			}else if(i!=1&&j==1&&c[i-1][7]<mday){
				c[i][j]=c[i-1][7]+1;
			}else if(i>1&&c[i][j-1]<mday&&c[i-1][7]<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<8;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;
}