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
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include <iostream>
#include <cmath>

using namespace std;

int main()
{  long long n; 
/* n to suma trzech liczb, n = a + b + c, n = a + aj + ajm, n = a (1 + j + jm), 
{a jest dzielnikiem liczby n}  n/a - 1 = j(1 + m) => j i (m + 1) są dzielnikami liczby n/a - 1 */


	int V = 0; //liczba szukanych trójek
	int a1, a2, a0; // dzielniki liczby
	int S1, S2, S0; // n/a - 1
	int j1, j2, j0; // j > 1
	
	// WARUNEK DO SPEŁNIENIA: (n/a - 1)/j - 1 > 1;
	
	cin >> n;
	
	for(int i = 1; i*i <= n; i++)
	{
		if(n%i == 0)
			if(n/i != i)
				{
					a1 = i;
					a2= n/i;
					S1 = n/a1 - 1;
					S2 = n/a2 - 1;
					
						for(int j = 2; j * j <= S1; j++)
				 		{
							if(S1%j == 0)
								if(S1/j != j)
									{
										j1 = j;							
										j2 = S1/j;
										
										if(S1/j1 - 1 > 1)	{
										V += 1;
										//cout<< a1 <<" "<< a1 * j1 << " " << a1 * j1 * (S1/j1 - 1) << endl;
										}
										if(S1/j2 - 1 > 1)
										{										
										V += 1;
										//cout<< a1 <<" "<< a1 * j2<< " " << a1 * j2 * (S1/j2 - 1) << endl;
										}
										
									}
								if(j * j == S1)
									{
										j0 = j;
										if(S1/j0 - 1 > 1)
										{										
										V += 1;
										//cout<< a1 <<" "<< a1 * j0 << " " << a1 * j0 * (S1/j0 - 1) << endl;
										}
									}
						}
						
						
						
						
						for(int j = 2; j * j <= S2; j++)
				 		{	
						 	if(S2%j == 0)
								if(S2/j != j)
									{
										j1 = j;							
										j2 = S2/j;
									
										if(S2/j1 - 1 > 1)
										{									
										V += 1;
										//cout<< a2 <<" "<< a2 * j1 << " " << a2 * j1 * (S2/j1 - 1) << endl;
										}
									
										if(S2/j2 - 1 > 1)
										{										
										V += 1;
										//cout<< a2 <<" "<< a2 * j2 << " " << a2 * j2 * (S2/j2 - 1) << endl;
										}
									}
								if(j * j == S2)
									{
										j0 = j;
									
										if(S2/j0 - 1 > 1)
										{										
										V += 1;
										//cout<< a2 <<" "<< a2 * j0 << " " << a2 * j0 * (S2/j0 - 1) << endl;
										}
									}
						}
						
					
					
				}
			if(i*i == n)
				{
					a0 = i;
					S0 = n/a0 - 1;
					
						for(int j = 2; j * j <= S0; j++)
				 		{	
						 	if(S0%j == 0)
								if(S0/j != j)
									{
										j1 = j;							
										j2 = S0/j;
									
										if(S0/j1 - 1 > 1)
										{
										V += 1;
										//cout<< a0 <<" "<< a0 * j1 << " " << a0 * j1 * (S0/j1 - 1) << endl;
										}
										
										if(S0/j2 - 1 > 1)
										{
										V += 1;
										//cout<< a0 <<" "<< a0 * j2 << " " << a0 * j2 * (S0/j2 - 1) << endl;
										}
										
									}
								if(j * j == S0)
									{
								 		j0 = j;
								 	
									 	if(S0/j0 - 1 > 1)
									 	{									
										V += 1;
										//cout<< a0 <<" "<< a0 * j0 << " " << a0 * j0 * (S0/j0 - 1) << endl;
										}
									}
						}
					
				}
		
	
	}
	
	
	
	
	
	
	cout << V;
	
return 0;

}