题目链接

思路:

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

公式: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. mysql导入本地文件(作业)

    1.准备本地文件(pet.txt) 2.在CMD中启动mysql服务,然后输入以下命令导入(pet.txt) load data local infile '路劲' into table pet; 3 ...

  2. 感觉不错的随笔 关于C、C++的

    [effective C++的网页版] http://www.kuqin.com/effectivec2e/ 内存四区模型 https://www.cnblogs.com/crazyzhang/p/5 ...

  3. caffe常用

    1. 关闭模型froward信息 os.environ[' #注意要在improt caffe之前 2. 学习率 step: 配合stepsize,迭代次数达到stepsize的整数倍改变一次, ba ...

  4. 日常开发自己遇到异常(BUG未完待续!!!)

    在面试的时候经常会被问到你在项目中遇到的bug有哪些,或者你感觉你解决什么问题让你感觉有成就感.以此类似的面试问答,楼主现在开始不断更新日常遇到的BUG汇总 1:ConcurentModificati ...

  5. 软件测试实验二----selenium、katalon、junit

    1.安装firefox和seleniumIDE.katalon 安装按成后在Firefox中有seleniumIDE.katalon的图标 2.使用katalon导出测试脚本 点击katalon的插件 ...

  6. javascript声明变量

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  7. vue 去中心化的路由拆分方案:require.context

    代码地址:https://github.com/lisiyizu/vue-router-dynamic

  8. MapReduce编程模型简介和总结

    MapReduce应用广泛的原因之一就是其易用性,提供了一个高度抽象化而变得非常简单的编程模型,它是在总结大量应用的共同特点的基础上抽象出来的分布式计算框架,在其编程模型中,任务可以被分解成相互独立的 ...

  9. centos 7 rabbitmq 3.7.12 erlang 20.3源码安装

    1.下载erlang 官网地址 http://www.erlang.org/download 挑选合适的版本 然后 建议20.3运行命令 wget http://erlang.org/download ...

  10. kubernets controller 和 CRD的扩展

    sample git repo 各个组件开发指导 operator 介绍 此图来自谷歌员工的实践介绍 client-go的使用和源码分析 (dlv) p pods *k8s.io/api/core/v ...