// @BEGIN_OF_SOURCE_CODE /* @JUDGE_ID: 17243NT 106 C++ "p^2 - q^2, 2pq, p^2 + q^2" */ // Send to judge@uva.es #include #include #include #ifdef ONLINE_JUDGE #define ins cin #define outs cout #else #define ins fin #define outs fout ifstream fin("myprog.in"); ofstream fout("myprog.out"); #endif bool comp[1000010]; int gcf(int a, int b) { int t; while(a > 0) { if(a < b) { t = a; a = b; b = t; } a = a % b; } return b; } int main() { int n, p, q, m, h, a, b; while(ins >> n) { for(p = 1; p <= n; p++) comp[p] = true; m = 0; for(p = 1; p * p <= n; p++) { for(q = 1; q < p && (h = p * p + q * q) <= n; q++) { a = p * p - q * q; b = 2 * p * q; if(gcf(gcf(a, b), h) == 1) { m++; for(int i = 1; i <= n / h; i++) { comp[a * i] = false; comp[b * i] = false; comp[h * i] = false; } } } } outs << m << ' '; m = 0; for(p = 1; p <= n; p++) if(comp[p]) m++; outs << m << endl; } return 0; } // @END_OF_SOURCE_CODE