Submission
Status:
PP-PPPPPPP
Subtask/Task Score:
90/100
Score: 90
User: evevevie
Problemset: เลขดวง
Language: c
Time: 0.002 second
Submitted On: 2025-10-02 18:19:58
#include <stdio.h>
int main(){
int maxdate, startdate, bday,i,j,row,column,x,y,wahaha=0;
int calendar[6][7];
for(i=0;i<6;i++){
for(j=0;j<7;j++){
calendar[i][j]=0;
}
}
scanf("%d", &maxdate);
scanf("%d", &startdate);
scanf("%d", &bday);
//karenda-mahou
i=1;
for(row=0;row<6;row++){
if(row==0){
for(column=startdate-1;column<7;column++){
if(i>maxdate){
break;
}
calendar[row][column]=i;
i++;
}
} else if(row>0&&row<6){
for(column=0;column<7;column++){
if(i>maxdate){
break;
}
calendar[row][column]=i;
i++;
}
}
}
/* calendar print test
for(i=0;i<6;i++){
for(j=0;j<7;j++){
printf(" %2d ", calendar[i][j]);
}
printf("\n");
}
*/
//pos det
x=startdate-1;
y=0;
for(i=1;i<=42;i++){
if(bday==calendar[y][x]){
break;
}
x++;
if(x==7){
y++;
x=0;
}
}
//sumtop
if(y==0){
wahaha+=0;
}else{
wahaha+=calendar[y+1][x];
}
//sumleft
if(x==0){
wahaha+=0;
}else{
wahaha+=calendar[y][x-1];
}
//sumright
if(x==6){
wahaha+=0;
}else{
wahaha+=calendar[y][x+1];
}
//sumdown
if(y==6){
wahaha+=0;
}else{
wahaha+=calendar[y-1][x];
}
//output
printf("%d", wahaha);
}