zoukankan      html  css  js  c++  java
  • CSU

    费马大定理:当n>2时,不定方程an+bn=cn没有正整数解。比如a3+b3=c3没有正整数解。为了活跃气氛,我们不妨来个搞笑版:把方程改成a3+b3=c3,这样就有解了,比如a=4, b=9, c=79时43+93=793。

    输入两个整数x, y, 求满足x<=a,b,c<=y的整数解的个数。

    Input
    输入最多包含10组数据。每组数据包含两个整数x, y(1<=x,y<=108)。

    Output
    对于每组数据,输出解的个数。

    Sample Input
    1 10
    1 20
    123 456789
    Sample Output
    Case 1: 0
    Case 2: 2
    Case 3: 16

    //感觉自己最这一类题做的神经有点错乱了,总以为会超时,然后就不敢做。。
    #include<map>
    #include<queue>
    #include<stack>
    #include<vector>
    #include<math.h>
    #include<cstdio>
    #include<sstream>
    #include<numeric>//STL数值算法头文件
    #include<stdlib.h>
    #include <ctype.h>
    #include<string.h>
    #include<iostream>
    #include<algorithm>
    #include<functional>//模板类头文件
    using namespace std;
    
    typedef long long ll;
    const int maxn=1100;
    const int INF=0x3f3f3f3f;
    
    int main()
    {
        int x,y,ans;
        int cas=1;
        while(scanf("%d %d",&x,&y)!=EOF)
        {
            ans=0;
            for(int a=x; a<=y; a++)
            {
                for(int b=x; b<=y; b++)
                {
                    ll s=a*a*a+b*b*b;
                    if(s/10>y)break;
                    if(s%10==3)
                    {
                        if((s/10)>=x&&(s/10)<=y)
                            ans++;
                    }
                }
                if((a*a*a+x*x*x)/10>y)
                    break;
            }
            printf("Case %d: %d
    ",cas++,ans);
        }
    }
    
  • 相关阅读:
    UI层复习笔记
    async 的三大返回类型
    用scikit-learn进行LDA降维
    关于解决python线上问题的几种有效技术
    ASP.NET Core MVC/WebAPi 模型绑定探索
    浅谈 Fragment 生命周期
    vue2.0实践的一些细节
    Linux----------Mysql死锁
    Linux----------容器docker file
    Linux----------常用容器命令
  • 原文地址:https://www.cnblogs.com/nyist-xsk/p/7264830.html
Copyright © 2011-2022 走看看