# 題目: UVa 12908 - The book thief

# 題目說明

給一個整數ss符合1 + 2 + 3 + ... + n - x,也就是從1開始的累加,但其中少了一頁
其中n為總頁數、x為缺少的頁碼
ns


INPUT:
每筆測資輸入一個整數s
s0時結束


OUTPUT:
輸出缺少的頁碼x與總頁數n

# 解題方法

使用一個變數sum維持現在的累加值,i為累加的次數
sum > s時,sum - s即為缺少的頁碼,i即為總頁數

# 參考程式碼

#include <iostream>

using namespace std;

static auto fast_io = []
{
	ios::sync_with_stdio(false);
	cout.tie(nullptr);
	cin.tie(nullptr);
	return 0;
}();

int main()
{
	int n;

	while (cin >> n, n)
	{
		int i = 0, sum = 0;
		while (sum <= n) sum += ++i;
		cout << sum - n << " " << i << "\n";
	}
}