题目链接

思路:

勾股数组,又称毕达格拉斯三元组。

公式:a = s*t  b = (s^2 - t^2) / 2  c = (s^2 + t^2) / 2  s > t >=1 且为互质的奇数

代码:

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head const int N = ;
int cnt[N+];
int main() {
for (LL s = ; ; s += ) {
if(s > N) break;
for (LL t = ; t < s; t += ) {
LL a = s*t, b = (s*s - t*t)/, c = (s*s + t*t)/;
if(a > N || b > N || c > N) break;
if(__gcd(s, t) > ) continue;
if(a+b+c > N) continue;
LL tot = a+b+c;
for (LL i = tot; i <= N; i += tot) cnt[i]++;
}
}
int ans = ;
for (int i = ; i <= N; ++i) if(cnt[i] == ) ans++;
cout << ans << endl;
return ;
}

Project Euler 75: Singular integer right triangles的更多相关文章

  1. Project Euler 75:Singular integer right triangles

    题目链接 原题: It turns out that 12 cm is the smallest length of wire that can be bent to form an integer ...

  2. Project Euler 44: Find the smallest pair of pentagonal numbers whose sum and difference is pentagonal.

    In Problem 42 we dealt with triangular problems, in Problem 44 of Project Euler we deal with pentago ...

  3. Project Euler 第一题效率分析

    Project Euler: 欧拉计划是一系列挑战数学或者计算机编程问题,解决这些问题需要的不仅仅是数学功底. 启动这一项目的目的在于,为乐于探索的人提供一个钻研其他领域并且学习新知识的平台,将这一平 ...

  4. Python练习题 039:Project Euler 011:网格中4个数字的最大乘积

    本题来自 Project Euler 第11题:https://projecteuler.net/problem=11 # Project Euler: Problem 10: Largest pro ...

  5. [project euler] program 4

    上一次接触 project euler 还是2011年的事情,做了前三道题,后来被第四题卡住了,前面几题的代码也没有保留下来. 今天试着暴力破解了一下,代码如下: (我大概是第 172,719 个解出 ...

  6. Python练习题 029:Project Euler 001:3和5的倍数

    开始做 Project Euler 的练习题.网站上总共有565题,真是个大题库啊! # Project Euler, Problem 1: Multiples of 3 and 5 # If we ...

  7. Project Euler 9

    题意:三个正整数a + b + c = 1000,a*a + b*b = c*c.求a*b*c. 解法:可以暴力枚举,但是也有数学方法. 首先,a,b,c中肯定有至少一个为偶数,否则和不可能为以上两个 ...

  8. project euler 169

    project euler 169 题目链接:https://projecteuler.net/problem=169 参考题解:http://tieba.baidu.com/p/2738022069 ...

  9. 【Project Euler 8】Largest product in a series

    题目要求是: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × ...

随机推荐

  1. 短信外部浏览器H5链接一键跳转微信打开任意站

    今天讲讲微信跳转的那些事情,这项技术最早出现在在线广告上面,可以从外部引流到微信并打开微信内置浏览器然后打开一个指定的网页地址,在这个网页里面可以放任何想推广的内容,可以是引导文案.活动内容,或者是一 ...

  2. C++模板的要点

    1.函数模板与普通函数的区别: 普通函数可以进行自动类型转化,而函数模板不可以. 举个例子 //函数模板 template<class T> void show(T a,T b){ cou ...

  3. Java之.jdk卸载-Linux

    Java之.jdk卸载-Linux 卸载Linux自带的jdk 首先查询: #  rpm -qa | grep jdk 使用root账户,进行卸载: # yum -y remove xxxxxxxx( ...

  4. 简介一下 i++和++i&&i=i+i,i+=1;的区别

    首先: int i=2; i++=2; ++i=3; 前者先显示当前的值,而后者则是先自增在显示值: second i=i+1和i+=1; 输出结果虽然一样,但是 1.byte i=2; i+=2; ...

  5. WPF线程中获取控件的值和给控件赋值

    WPF中使用线程操作控件,按平常的操作方法操作的话会报异常:调用线程无法访问此对象,因为另一个线程拥有该对象.所以我们要使用Dispatcher类的BeginInvoke()与Invoke()方法.B ...

  6. SSIS Hekaton In-Memory OLTP 【翻译一篇外国文章】

    来自:http://www.itprotoday.com/microsoft-sql-server/important-new-features-sql-server-2014 Microsoft's ...

  7. 【Qt官方MQTT库的使用,附一个MqttClient例子】

    Qt官方MQTT库的使用,附一个MqttClient例子 开发环境:win7 64 + Qt5.9 记录时间:2018年3月11日 00:48:42 联系邮箱: yexiaopeng1992@126. ...

  8. IDEA SpringBoot 打包(jar)

    项目结构: sf-xxx-api sf-xxx-domain sf-xxx-common sf-xxx-web (web模块) 期望输出结果目录 bin/server.sh libs/**.jar,* ...

  9. PHP 不同类型之间的松散和严格比较

    原始数据类型 在比较之前先简单介绍一下PHP的9种原始数据类型,包括 四种标量类型: boolean(布尔型) integer(整型) float(浮点型,也称作 double) string(字符串 ...

  10. SDK?JDK?JDK 下载、安装、配置图文教程

    什么是软件开发工具包(SDK)   开发一个软件,需要经过编辑.编译.调试.运行几个过程. 编辑:使用编程语言编写程序代码的过程. 编译:如上一节所讲,就是将编写的程序进行翻译. 调试:程序不可能一次 ...