Problem J
Joking with Fermat's Last Theorem
Fermat's Last Theorem: no three positive integers a, b, and c can satisfy the equation an + bn = cn for any integer value of n greater than two.
From the theorem, we know that a3 + b3 = c3 has no positive integer solution.
However, we can make a joke: find solutions of a3 + b3 = c3. For example 43 + 93 = 793, so a=4, b=9, c=79 is a solution.
Given two integers x and y, find the number of solutions where x<=a,b,c<=y.
Input
There will be at most 10 test cases. Each test case contains a single line: x, y (1<=x<=y<=108).
Output
For each test case, print the number of solutions.
Sample Input
1 101 20123 456789
Output for the Sample Input
Case 1: 0Case 2: 2Case 3: 16
The Ninth Hunan Collegiate Programming Contest (2013) Problemsetter: Rujia Liu Special Thanks: Md. Mahbubul Hasan, Feng Chen
这道题有一个突破口,就是a, b <=1000 ,这样子算法就变成了 O(1000*1000)。
#include#include #include #include #include #include #include #include #include #include