MCPcopy Create free account
hub / github.com/E869120/math-algorithm-book / main

Function main

codes/cpp/Code_5_04_1.cpp:6–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4using namespace std;
5
6int main() {
7 // ����
8 int N, K;
9 cin >> N >> K;
10
11 // ���� B �̌� yojishou �𐔂��� �� �����̏o��
12 long long yojishou = 0;
13 for (int a = 1; a <= N; a++) {
14 for (int b = max(1, a - (K - 1)); b <= min(N, a + (K - 1)); b++) {
15 for (int c = max(1, a - (K - 1)); c <= min(N, a + (K - 1)); c++) {
16 if (abs(b - c) <= K - 1) yojishou += 1;
17 }
18 }
19 }
20 cout << (long long)N * N * N - yojishou << endl;
21 return 0;
22}

Callers

nothing calls this directly

Calls 2

minFunction · 0.85
maxFunction · 0.50

Tested by

no test coverage detected