poj1305:概念水题
了解一下毕达哥拉斯三元组概念= =
暴力求出所有的本源三元组即可
代码:
#include <iostream>
#include <stdio.h>
#include<string.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<ctype.h>
using namespace std;
#define MAXN 10000
int n;
bool vi[];
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("shu.txt","r",stdin);
#endif
while(scanf("%d",&n)!=EOF)
{
memset(vi,,sizeof(vi));
int ans1=;
int ans2=;
for(int i=;;i++)
{
if(i*i+(i+)*(i+)>n)
break;
for(int j=i+;;j++)
{
if(i*i+j*j>n)
break;
if((i%)==(j%))
continue;
if(gcd(i,j)!=)
continue;
int x=j*j-i*i;
int y=*i*j;
int z=i*i+j*j;
ans1++;
for(int k=;k*z<=n;k++)
{
vi[k*x]=vi[k*y]=vi[k*z]=;
}
}
}
for(int i=;i<=n;i++)
ans2+=!vi[i];
printf("%d %d\n",ans1,ans2);
}
return ;
}
poj1305:概念水题的更多相关文章
- 水题两篇 Dream & Find Integer (HDU 6440/6441)
// 出自ICPC 2018网络赛C - Dream & D - Find Integer // 对大佬来讲的水题,本菜鸡尽量学会的防爆零题... // 今晚翻看vjudge昨日任务上的C题, ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,
1195: 相信我这是水题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 821 Solved: 219 Description GDUT中有个风云人 ...
- BZOJ 1303 CQOI2009 中位数图 水题
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2340 Solved: 1464[Submit][Statu ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- ACM水题
ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...
随机推荐
- iOS8及以后 地图定位当前城市
通过以下网址的步骤实现定位获取城市的功能 http://www.2cto.com/kf/201504/393312.html
- i++与++i的区别,使用实例说明
/** * 类名:TEST.java<br> * <p> * 功能:i++与++i的区别,使用实例说明 * </p> * * @Author:<a href= ...
- Bestcoder #47 B Senior's Gun
Senior's Gun Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tot ...
- [Javascript] JSON.parse API
JSON (JavaScript Object Notation) is a standard method to serialize JavaScript objects and is common ...
- Codeforces 328A-IQ Test(数列)
A. IQ Test time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- 完全卸载sql2005
转自:http://www.cnblogs.com/mytechblog/articles/1883961.html 1.Stop 所有服务 2.在控制面板中卸载所有与SQL Server 2005相 ...
- Cycling Label
Cycling Label 来源: github/BBCyclingLabel Licence: Apache 2.0 作者: Bruno de Carvalho 分类: 标签(Label) 平台: ...
- css float父元素高度塌陷
css float父元素高度塌陷 float 使父元素高度塌陷不是BUG,反而是标准. float 原本是为了解决文字环绕才出现的. 当然有的时候要解决高度塌陷的问题 以下几个方法可以解决float ...
- Web文件管理:elFinder.Net(支持FTP)
elFinder 是一个基于 Web 的文件管理器,灵感来自 Mac OS X 的 Finder 程序. elFinder.Net是.Net版本的一个Demo,使用ASP.NET MVC 4集成,可以 ...
- scala学习笔记-集合
变长数组:数组缓冲 Scala中对于那种长度会变的数组的数据结构为ArrayBuffer. import scala.collection.mutable.ArrayBuffer; // 一个空的数组 ...