CSU 1337 搞笑版费马大定理(2013湖南省程序设计竞赛J题)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1337
解题报告:虽然x和y的范围都是10^8,但是如果a 是大于1000的话,那么a^3就会大于10^9,这样等号的右边只有一个10 * c + 3,这个最大只能达到10^9数量级,所以,不管输入的x跟y是多少,我们只要取其中的在1到1000的区间就可以了,枚举a和b,那么c就可以得到,然后判断c的范围是不是在x到y之间,这样时间复杂度就降到了10^6.
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long INT;
INT th[];
void dabiao()
{
for(INT i = ;i <= ;++i)
th[i] = i * i * i;
}
int main()
{
dabiao();
INT x,y;
int kase = ;
while(scanf("%lld%lld",&x,&y)!=EOF)
{
INT ans = ;
INT a = min(x,(INT)); //不存在大于1000的
INT b = min(y,(INT));
for(INT i = a;i <= b;++i)
for(INT j = a;j <= b;++j)
{
INT s = th[i] + th[j];
if(s % == && s / <= y)
ans++;
}
printf("Case %d: %lld\n",kase++,ans);
}
return ;
}
CSU 1337 搞笑版费马大定理(2013湖南省程序设计竞赛J题)的更多相关文章
- CSU 1337 搞笑版费马大定理【优化枚举】
费马大定理:当n>2时,不定方程an+bn=cn没有正整数解.比如a3+b3=c3没有正整数解.为了活跃气氛,我们不妨来个搞笑版:把方程改成a3+b3=c3,这样就有解了,比如a=4, b=9, ...
- CSU 1328 近似回文词(2013湖南省程序设计竞赛A题)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1328 解题报告:中文题题意就不说了.还好数据不大,只有1000,枚举回文串的中心位置,然 ...
- csuoj 1337: 搞笑版费马大定理
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1337 1337: 搞笑版费马大定理 Time Limit: 1 Sec Memory Limit ...
- CSU 1503 点到圆弧的距离(2014湖南省程序设计竞赛A题)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1503 解题报告:分两种情况就可以了,第一种是那个点跟圆心的连线在那段扇形的圆弧范围内,这 ...
- 2012年湖南省程序设计竞赛E题 最短的名字
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1115 解题报告:输入n个字符串,让你求出可以用来区别这些字符串的最少的前缀总共有多少个字 ...
- 2013年山东省第四届ACM大学生程序设计竞赛J题:Contest Print Server
题目描述 In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source code ...
- hdu6489 2018 黑龙江省大学生程序设计竞赛j题
Problem Description Kayaking is playing a puzzle game containing n different blocks. He marks the bl ...
- 舔狗【2019河北省大学生程序设计竞赛 J题】
题目描述 > “舔狗舔狗,> 舔到最后,> 一无所有.” 有 n 只舔狗,每只舔狗的心中都有自己朝思暮想的一位. 每个人虽然受到了一万次拒绝,还毅然第一万零一次鼓起勇气. 作为一个不 ...
- J - 搞笑版费马大定理
J - 搞笑版费马大定理 Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%lld & %llu Submit ...
随机推荐
- juqery 实现商城循环倒计时
<html> <hand> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jqu ...
- cocos2d 2.2.6 win7下的配置
我搭建cocos2.6的开发环境需要安装工具包括: 1.Visual Studio 2012(由于不兼容win7,需要安装Update 4)和虚拟光驱daemon tool,虚拟光驱的下载地址:htt ...
- Ubuntu系统安装(win7双系统)
ubuntuan安装 1.安装方法及工具 1. 安装方法介绍 本人采用的是LiveUSB安装方法,也就是通常所说的U盘安装. 2.工具 硬件工具:U盘,华硕A53s电脑(我的是win7系统) 软件工具 ...
- paramiko模块使用
paramiko是一个用于做远程控制的模块,使用该模块可以对远程服务器进行命令或文件操作,fabric和ansible内部远程管理就是使用paramiko来实现. #!/usr/bin/env pyt ...
- OpenGL Tutorial
https://open.gl https://www.processing.org/tutorials/pshader/
- .NET软件开发与常用工具清单(转)
http://www.cnblogs.com/smileberry/p/4047835.html
- Autofac IContainer 测试
using Autofac; using System; using System.Collections.Generic; using System.Linq; using System.Text; ...
- autofac获取全局Container
_UserService = ((IContainerProviderAccessor)HttpContext.Current.ApplicationInstance).ContainerProvid ...
- Yii2 使用八 使用scenarios
在model里定义 public function scenarios() { return [ 'add' => ['title', 'content'], ]; } 在rules里定义 [[ ...
- linux下svn的命令
原文地址:http://www.cnblogs.com/wanqieddy/archive/2011/06/09/2076783.html