The theory of Fei Ma, the funny edition of Hunan's ninth College Students' Computer Programming Competition

Source: Internet
Author: User

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;}




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.