Project Euler Problem 9-Special Pythagorean triplet
我是俩循环暴力
看了看给的文档,英语并不好,有点懵,所以找了个中文的博客看了看:勾股数组学习小记。里面有两个学习链接和例题。
import math
def calc():
for i in range(1,1000):
j = i+1
while j <= 1000:
c = i*i+j*j
c = int(math.sqrt(c))
if i+j+c > 1000:
break
if i < j < c and i+j+c == 1000 and i*i+j*j == c*c:
return i,j,c
j += 1
return 0,0,0
a,b,c = calc()
print a,b,c
print a*b*c
Project Euler Problem 9-Special Pythagorean triplet的更多相关文章
- projecteuler Problem 9 Special Pythagorean triplet
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 Fo ...
- Problem 9: Special Pythagorean triplet
flag = 0 for a in range(1,1000): for b in range(a+1,1000): if a*a + b*b == (1000-a-b)**2: print(a,b) ...
- (Problem 9)Special Pythagorean triplet
A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For exampl ...
- Special Pythagorean triplet
这个比较简单,慢慢进入状态. A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = ...
- Project Euler 106:Special subset sums: meta-testing 特殊的子集和:元检验
Special subset sums: meta-testing Let S(A) represent the sum of elements in set A of size n. We shal ...
- Project Euler 103:Special subset sums: optimum 特殊的子集和:最优解
Special subset sums: optimum Let S(A) represent the sum of elements in set A of size n. We shall cal ...
- Project Euler Problem 10
Summation of primes Problem 10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of ...
- Project Euler problem 62
题目的大意很简单 做法的话. 我们就枚举1~10000的数的立方, 然后把这个立方中的有序重新排列,生成一个字符串s, 然后对于那些符合题目要求的肯定是生成同一个字符串的. 然后就可以用map来搞了 ...
- Project Euler problem 63
这题略水啊 首先观察一下. 10 ^ x次方肯定是x + 1位的 所以底数肯定小于10的 那么我们就枚举1~9为底数 然后枚举幂级数就行了,直至不满足题目中的条件即可break cnt = 0 for ...
随机推荐
- Leetcode17.Letter Combinations of a Phone Number电话号码的字母组合
给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合. 给出数字到字母的映射如下(与电话按键相同).注意 1 不对应任何字母. 示例: 输入:"23" 输出:[&quo ...
- Leetcode637.Average of Levels in Binary Tree二叉树的层平均值
给定一个非空二叉树, 返回一个由每层节点平均值组成的数组. class Solution { public: vector<double> averageOfLevels(TreeNode ...
- itextsharp 1.0
1 效果图 2.代码 引用组件: using iTextSharp.text;using iTextSharp.text.pdf;using System;using System.Data;usin ...
- cf round 480E The Number Games
题意:给一棵树,点$i$的点权是$2^i$,你需要删掉$k$个点,使得剩下的点连通的情况下剩下的点权值和最大. $k \leq n \leq 10^6$ 如果考虑删哪些点,是不好考虑的,会出问题. 反 ...
- LINUX下C++编程如何获得某进程的ID
#include <stdio.h> #include <stdlib.h> #include <unistd.h> using namespace std; pi ...
- 【linux配置】在VMware中为Redhat HAT配置本地yum源
在VMware中为Redhat HAT配置本地yum源 今天准备使用CM安装大数据环境,到需要几台机器都使用同一套yum源才可以,所以想到将Redhat镜像文件拷贝到虚拟机中,在挂起使用,最后通过ht ...
- StringBuilder / StringBuffer类
StringBuilder类 和 StringBuffer 类的由来? 在Java中使用String 类可以描述所有的字符串数据,但是String类的对象一旦创建,则该对象的字符序列 就不可更改,当需 ...
- Direct2D 第6篇 绘制多种风格的线条
原文:Direct2D 第6篇 绘制多种风格的线条 上图是使用Direct2D绘制的线条,Direct2D在效率上比GDI/GDI+要快几倍,GDI/GDI+绘图是出了名的"慢", ...
- vue移动端项目
用vue mint-ui jquery-weui写了一个移动端demo 技术栈 vue2.0 vue-router axios mint-ui jquery-weui webpack 页面截图 最后 ...
- 【机器学习PAI实战】—— 玩转人工智能之美食推荐
前言 在生活中,我们经常给朋友推荐一些自己喜欢的东西,也时常接受别人的推荐.怎么能保证推荐的电影或者美食就是朋友喜欢的呢?一般来说,你们两个人经常对同一个电影或者美食感兴趣,那么你喜欢的东西就很大程度 ...