Funny free horse theorem time limit: 1 sec memory limit: 128 MB
Submit: 190 solved: 93
[Submit] [Status] [web board] Description
Ferma's theorem: WHEN n> 2, there is no positive integer solution for the Indefinite Equation an + BN = cn. For example, A3 + B3 = C3 has no positive integer solution. For an active atmosphere, let's make a funny version: change the equation to A3 + B3 = C3, so there is a solution, such as a = 4, B = 9, C = 79 at 43 + 93 = 793.
Enter two integers x and y to calculate the number of integer solutions that meet the conditions of x <= A, B, C <= y.
Input
The input can contain up to 10 groups of data. Each group of data contains two integers x and y (1 <= X, Y <= 108 ).
Output
The number of outputs for each group of data.
Sample Input
1 101 20123 456789
Sample output
Case 1: 0Case 2: 2Case 3: 16
Hintsource
Hunan ninth College Computer Program Design Competition
Enumeration..., mainly to block out the range, otherwise timeout
The AC code is as follows:
#include<iostream>#include<cmath>#include<cstring>#include<stdio.h>using namespace std;int main(){ int x,y; int a,b,c; int i,j; int cas=1; int l,ans,sum,bj; while(~scanf("%d%d",&x,&y)) { sum=0;bj=0; for(i=x;i*i*i<=y*10;i++) { for(j=i;j*j*j<=y*10;j++) { ans=i*i*i+j*j*j; if(ans%10==3&&ans/10>=x&&ans/10<=y) { sum+=2; //cout<<i<<" "<<j<<endl; if(i==j) sum--; } if(2*i*i*i/10>y) {break;bj=1;} } if(bj) break; } cout<<"Case "<<cas++<<":"<<" "; cout<<sum<<endl; } return 0;}