-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path023-star-arrangements.cpp
More file actions
50 lines (43 loc) · 1.16 KB
/
Copy path023-star-arrangements.cpp
File metadata and controls
50 lines (43 loc) · 1.16 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Star Arrangements [101652X]
* Problem: Gym/ICPC contest 101652 - problem X
* Verdict: ACCEPTED Solved: 2025-10-24
* Language: C++23 (GCC 14-64, msys2)
* Runtime: 62 ms Memory: 0 KB
* Tags: n/a
* Author: team "balls" (HossamIsmail, BidoTeima, a1abay)
* Source: https://codeforces.com/gym/101652/submission/345431628
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int S;
cin >> S;
set<pair<int,int>> st;
for(int x = 1; x < S; x++){
if(S % (2 * x + 1) == 0){
st.insert({x + 1, x});
}
if(S % x == 0){
st.insert({x, x});
}
// (a + 1)(x + 1) + a(x) = S
// a(x + 1) + (x + 1) + a(x) = S
// a(2x + 1) = S - (x + 1)
// a = (S - (x + 1))/(2x + 1)
if(S > (x + 1) && (S - (x + 1)) % (2 * x + 1) == 0){
st.insert({x + 1, x});
}
}
cout<<S<<":\n";
for(auto&it : st){
if(it.first == 1 || it.first == S) continue;
cout << it.first << ',' << it.second << '\n';
}
return 0;
}