Submission

Status:

P---------

Subtask/Task Score:

10/100

Score: 10

User: NovemNotes

Problemset: เลขดวง

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-15 10:42:43

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

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    // 6 7
    vector<vector<int>> cal(7,vector<int>(8,0));
    int day,st,want,x,y;
    cin >> day >> st >> want;
    int now=1;
    int stx=1,sty=st;
    while(now<=day){
        if(now==want){
            x=stx,y=sty;
        }
        cal[stx][sty]=now++;
        sty++;
        if(sty==8){
            sty=1;
            stx++;
        }
    }
    // for(int i=1;i<=6;i++){
    //     for(int j=1;j<=7;j++){
    //         if(cal[i][j]>0){
    //             if(cal[i][j]<10){
    //                 cout << " " << cal[i][j];
    //             }else{
    //                 cout << cal[i][j];
    //             }
    //             cout << " ";
    //         }else
    //             cout << "   ";
    //     }
    //     cout << "\n";
    // }
    int left = cal[x][1],right = cal[x][7] , up = (cal[0][y]==0? cal[1][y]:cal[0][y]) , down = (cal[6][y]==0? cal[5][y]:cal[6][y]);
    if(left==want)left=0;
    if(right==want)right=0;
    if(up==want)up=0;
    if(down==want)down=0;
    // cout << up << " " << down << " " << left << " " << right << "\n";
    cout << up+down+right+left << "\n";
    return 0;
}