code:
<span style="font-size:18px;">#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream in("input.txt");
int n, i, k, j;
while (cin >> n && n != 0)
{
int sum = 0, total = 0;
for (i = 1; i <= n; i++)
{
sum += i;
for (j = 1; j <= i; j++)
{
total += i;
}
if (sum <= n && sum + i + 1 > n)
break;
}
if (sum < n)
{
for (j = 1; j <= n - sum; j++)
total = total + i + 1;
}
cout << n << " " << total << endl;
}
//system("pause");
return 0;
}
</span>