PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000069. Vị trí nguyên tố trong tam giác (Primes Triangle (I))
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Vị trí nguyên tố trong tam giác (Primes Triangle (I))
Primes Triangle (I)
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Arrange increasing primes into a triangle: row has ; row has ; row has ; row has ; and row has primes. Rows and columns are indexed from . Given positive integer , print its row and column in this triangle if is prime; otherwise report that it does not appear.
Input
One line contains integer .
Output
If is prime, print two integers : its one-based row and column. Otherwise print -1.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
23
Output
4 3
Explanation
The primes start . The prime has rank . The first three rows contain entries, so lies in row . That row is , making its column : print 4 3.