/* -*- coding: utf-8 -*- * * 3156.cc: No.3156 Count That Day's N - yukicoder */ #include #include #include #include using namespace std; /* constant */ /* typedef */ using ll = long long; using sl = set; /* global variables */ /* subroutines */ inline ll pow4(ll x) { return x * x * x * x; } inline ll pow6(ll x) { return pow4(x) * x * x; } /* main */ int main() { ll k, n; scanf("%lld%lld", &k, &n); //printf("k=%lld, n=%lld\n", k, n); sl as; for (ll x = 1, x6; (x6 = pow6(x)) <= n; x++) for (ll y = 1, a; (a = x6 + pow4(y)) <= n; y++) { ll z = sqrt(0.5 + a / k); if (z > 0 && a == z * z * k) as.insert(a); } printf("%d\n", (int)as.size()); return 0; }