PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000145. Đồ thị nguyên tố (Prime Graph)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đồ thị nguyên tố (Prime Graph)
Prime Graph
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Construct an undirected simple graph on exactly vertices, with a prime number of edges and prime degree at every vertex. The graph need not be connected. Output -1 if impossible, otherwise any valid graph.
Input
A line containing .
Output
Print followed by edges, or -1.
Subtask
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Example
Input
4
Output
5
1 2
2 3
3 4
4 1
1 3
Explanation
There are five edges, a prime number; vertex degrees are , all prime. The graph is simple.