Problem4541--数对排序

4541: 数对排序

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MiB

Description

由两个自然数组成的一对数称之为有序数对。有序是指数对的第一项与第二项是区别的,例如 lns="http://www.w3.org/1998/Math/MathML">(0,1)lns="http://www.w3.org/1998/Math/MathML">(1,0) 是不一样的数对。

我们对所有的有序数对进行排序,排序规则如下:

  • 首先,计算每个数对的两数之和,和较小的数对靠前排列;
  • 其次,如果两数之和一样大,则数对中第一项较小的数对靠前排列。

按照这个规则排序,前 lns="http://www.w3.org/1998/Math/MathML">6 项数对为 

                                                    (0,0),(0,1),(1,0),(0,2),(1,1),(2,0)

给定一个整数 k,请求出第 k 个数对


Input

  • 单个整数 lns="http://www.w3.org/1998/Math/MathML">k
  •  的数据,lns="http://www.w3.org/1998/Math/MathML">1k1,000
  • lns="http://www.w3.org/1998/Math/MathML">60% 的数据,lns="http://www.w3.org/1998/Math/MathML">1k1,000,000
  • lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">1k1,000,000,000



Output

  • 两个整数:表示第 lns="http://www.w3.org/1998/Math/MathML">k 个有序数对

Sample Input Copy

6

Sample Output Copy

2 0

Source/Category