标签:des style blog http color os io for
2 10 19
Case #1: 0 Case #2: 1Hint10 shown in hexadecimal number system is another letter different from ‘0’-‘9’, we can represent it as ‘A’, and you can extend to other cases#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <cmath> typedef __int64 ll; using namespace std; ll n, ans; int main() { int t, cas = 1; scanf("%d", &t); while (t--) { scanf("%I64d", &n); if (n >= 3 && n <= 6) { printf("Case #%d: -1\n", cas++); continue; } ans = 0; for (ll i = 3; i <= 6; i++) for (ll j = 3; j <= 6; j++) if ((n-j)%i == 0 && (n-j)/i > max(i, j)) ans++; for (ll i = 3; i <= 6; i++) for (ll j = 3; j <= 6; j++) for (ll k = 3; k <= 6; k++) { ll a = i, b = j, c = k - n; ll tmp = (ll) sqrt(b*b - 4*a*c + 0.5); if (tmp*tmp != b*b - 4*a*c) continue; if ((tmp-b)%(2*a) != 0) continue; ll cnt = (tmp-b)/(2*a); if (cnt > max(max(i, j), k)) ans++; } for (ll i = 2; i*i*i <= n; i++) { ll tmp = n; while (tmp) { if (tmp % i < 3 || tmp % i > 6) break; tmp /= i; } if (tmp == 0) ans++; } printf("Case #%d: %I64d\n", cas++, ans); } return 0; }
HDU - 4937 Lucky Number,布布扣,bubuko.com
标签:des style blog http color os io for
原文地址:http://blog.csdn.net/u011345136/article/details/38538129