题目描述

题解代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 #include<bits/stdc++.h>
using namespace std;
const int N=2*10e5+10;
typedef long long ll;

ll n;
int main()
{ cin>>n;

for(int i=1;i<=n/2;i++)

{ ll l=1; ll r=n/2+1;
int sum=0;
while(l<r)
{ ll mid=l+r>>1;
ll sum=(i+mid)*(mid-i+1)>>1;
if(sum>=n) r=mid;
else l=mid+1;




}
if((i+l)*(l-i+1)/2==n)
cout<<i<<" "<<l<<endl;


}




}

题目思路