#include<bits/stdc++.h>
using namespace std;
long long s,n,i;//定义
int main()
{
cin>>n;//输入
i=round(sqrt(n*2));
while(i>=2)//while循环
{
s=(n*2-i*(i-1))/i/2;
if((s+s+i-1)*i/2==n) cout<<s<<' '<<s+i-1<<endl; //高斯公式
i--;
}
}
有趣的数学 (math.pas/c/cpp)c++代码
最新推荐文章于 2025-05-14 18:47:04 发布