Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: colo39
Problemset: เลขดวง
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-01 13:47:52
#include <bits/stdc++.h>
using namespace std;
int arr[10][10];
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
bool ch = 0;
int a,b,c;
cin >> a >> b >> c;
arr[1][b] = 1;
int c_x, c_y;
int d = 2;
for (int i = 1;i <= 5;i++) {
if (i == 1) {
for (int j = b+1;j <= 7;j++) {
if (d > a) {
ch = 1;
break;
}
arr[i][j] = d;
if (d == c) {
c_x = i;
c_y = j;
}
d++;
}
} else {
for (int j = 1;j <= 7;j++) {
if (d > a) {
ch = 1;
break;
}
arr[i][j] = d;
if (d == c) {
c_x = i;
c_y = j;
}
d++;
}
}
if (ch) break;
}
/*for (int i = 1;i <= 5;i++) {
for (int j = 1;j <= 7;j++) {
cout << arr[i][j]<< " ";
}
cout << endl;
}*/
cout << arr[c_x+1][c_y] + arr[c_x-1][c_y] + arr[c_x][c_y+1] + arr[c_x][c_y-1];
}