欧拉工程第53题:Combinatoric selections
package projecteuler51to60;
class p53{
void solve1(){
int count=0;
int Max=1000000;
int[][] table=new int[101][101];
for(int row=0;row<=100;row++){
table[row][0]=table[row][row]=1;
for(int col=1;col<=row-1;++col){
table[row][col]=table[row-1][col]+table[row-1][col-1];
if(table[row][col]>Max || table[row][col]< 0){
++count;
}
}
}
System.out.println(count);
}
void solve0(){
int count=0;
int Max=1000000;
boolean tag=true;
for(int n=23;n<=100;n++){
tag=true;
for(int r=0;tag==true&& r<=n/2;r++){
long c=choose(n,r);
if(c>Max){
count+=n+1-2*r;
tag=false;
}
}
}
System.out.println(count);
}
long choose(int n,int r){
long res=1;
for(int i=n-r+1;i<=n;i++)
res*=i;
for(int i=1;i<=r;i++)
res/=i;
return res;
}
}
public class Problem53 {
public static void main(String[] args){
long begin= System.currentTimeMillis();
new p53().solve1();//
long end = System.currentTimeMillis();
long Time = end - begin;
System.out.println("Time:"+Time/1000+"s"+Time%1000+"ms");
}
}
欧拉工程第53题:Combinatoric selections的更多相关文章
- 欧拉工程第69题:Totient maximum
题目链接 欧拉函数φ(n)(有时也叫做phi函数)可以用来计算小于n 的数字中与n互质的数字的个数. 当n小于1,000,000时候,n/φ(n)最大值时候的n. 欧拉函数维基百科链接 这里的是p是n ...
- 欧拉工程第70题:Totient permutation
题目链接 和上面几题差不多的 Euler's Totient function, φ(n) [sometimes called the phi function]:小于等于n的数并且和n是互质的数的个 ...
- 欧拉工程第51题:Prime digit replacements
题目链接 题目: 通过置换*3的第一位得到的9个数中,有六个是质数:13,23,43,53,73和83. 通过用同样的数字置换56**3的第三位和第四位,这个五位数是第一个能够得到七个质数的数字,得到 ...
- 欧拉工程第67题:Maximum path sum II
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the ma ...
- 欧拉工程第66题:Diophantine equation
题目链接 脑补知识:佩尔方差 上面说的貌似很明白,最小的i,对应最小的解 然而我理解成,一个循环的解了,然后就是搞不对,后来,仔细看+手工推导发现了问题.i从0开始变量,知道第一个满足等式的解就是最小 ...
- 欧拉工程第65题:Convergents of e
题目链接 现在做这个题目真是千万只草泥马在心中路过 这个与上面一题差不多 这个题目是求e的第100个分数表达式中分子的各位数之和 What is most surprising is that the ...
- 欧拉工程第56题:Powerful digit sum
题目链接 Java程序 package projecteuler51to60; import java.math.BigInteger; import java.util.Iterator; im ...
- 欧拉工程第55题:Lychrel numbers
package projecteuler51to60; import java.math.BigInteger; import java.util.Iterator; import java.util ...
- 欧拉工程第54题:Poker hands
package projecteuler51to60; import java.awt.peer.SystemTrayPeer; import java.io.BufferedReader; impo ...
随机推荐
- scjp考试准备 - 7 - Java构造器
题目——如下代码的执行结果: class Hello{ String title; int value; public Hello(){ title += " World!"; } ...
- [转]HTTPS那些事(一)HTTPS原理
[转]HTTPS那些事(一)HTTPS原理 http://www.guokr.com/post/114121/ 楔子谣言粉碎机前些日子发布的<用公共WiFi上网会危害银行账户安全吗?>, ...
- IIS、SQL SERVER和VS的安装顺序
正确安装顺序:先安装IIS,再安装SQL SERVER,最后安装VS. 如果先安装VS后安装的IIS,则需要找到对应的.net framework目录下,执行aspnet_regiis.exe,重新注 ...
- SharePoint 2010 设置宽度1024px
在模板页中找到 s4-workspace,设置class=”s4-nosetwidth“,然后再设置宽度为1024px:如果要居中,设置style=“margin:0 auto” 这样也会有一个问题: ...
- Qt之SQL数据库
---------------------------- http://blog.csdn.net/reborntercel/article/details/6991147 http://blog.c ...
- C# 把引用的dll嵌入到exe文件中
当发布的程序有引用其它dll, 又只想发布一个exe时就需要把dll打包到exe 当然有多种方法可以打包, 比如微软的ILMerge,混淆器附带的打包... 用代码打包的实现方式也有很好,本文只是其中 ...
- Java 字符编码归纳总结
String newStr = new String(oldStr.getBytes(), "UTF-8"); java中的String类是按照unicode进行编码的 ...
- sourceInsight使用技巧,持续更新中~~~
作为测试人员,读各种平台的工程代码时,根本不想安装各种vs或者eclipse等,于是,就找了一款代码阅读工具. sourceInsight,下载地址为官网:http://www.sourceinsig ...
- Java 调用 Javascript 函数的范例
在Java 7 以后,可以在Java代码中调用javascript中的函数,请看下面的例子: package com.lee; import java.io.FileNotFoundException ...
- 【转】C#通过Expression获取指定属性的名称
原文:http://www.cnblogs.com/powerwu/articles/3393582.html 大家所熟悉的是通过对象属性来访问该属性的值,或是由字符串通过反射来获取属性,并取值.今天 ...