# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
9534 | silas | Wiring (kriii2_W) | C++98 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
using namespace std;
int q_before, q_after; // Qp-1, Qp
int P; // 단계를 나타내는 함수
int N; // 총 못의 개수
bool visited[1001][1001];
int main() {
memset(visited, 0, sizeof(visited));
cin >> N;
P = 1;
q_before = 0;
int solution = 0;
for (int i = 0 ; i < N*N; i++) {
q_after = (q_before + P) % N;
if (!visited[q_before][q_after] && !visited[q_after][q_before] && q_after != q_before) {
solution++;
visited[q_before][q_after] = true;
visited[q_after][q_before] = true;
}
P++;
q_before = q_after;
}
cout << solution << endl;
return 0;
}