Submission

Status:
PPPPPPPPPP

Score: 100

User: Namkhing

Problemset: เลขดวง

Language: cpp

Time: 0.003 second

Submitted On: 2025-04-10 23:07:40

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

const int N = 50;
int n, d, x, a[N][8];

int main() {
    cin.tie(nullptr)->ios_base::sync_with_stdio(false);
    cin >> n >> d >> x;
    int now = 1;
    int s = d;
    for (int i = 1; i <= n; i++) {
        a[now][d] = i;
        d++;
        if (d == 8) d = 1, now++;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= 7; j++) {
            if (a[i][j] == x) {
                cout << a[i-1][j] + a[i][j-1] + a[i][j+1] + a[i+1][j];
                return 0;
            }
        }
    }
}