#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%i", &n); long long counter = 0; int k; for(int i = 1; i <= n; i++) { for(int j = i+1; j <= n; j++) { k = n-i-j; if(j >= k) { break; } if(i+j+k == n) { if(max(i, j) % min(i, j) == 0 && max(i, k) % min(i, k) == 0 && max(j, k) % min(j, k) == 0) { //cout << i << " " << j << " " << k << endl; counter++; } } } } cout << counter << endl; return 0; }
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 | #include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%i", &n); long long counter = 0; int k; for(int i = 1; i <= n; i++) { for(int j = i+1; j <= n; j++) { k = n-i-j; if(j >= k) { break; } if(i+j+k == n) { if(max(i, j) % min(i, j) == 0 && max(i, k) % min(i, k) == 0 && max(j, k) % min(j, k) == 0) { //cout << i << " " << j << " " << k << endl; counter++; } } } } cout << counter << endl; return 0; } |