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的更多相关文章

  1. 欧拉工程第69题:Totient maximum

    题目链接 欧拉函数φ(n)(有时也叫做phi函数)可以用来计算小于n 的数字中与n互质的数字的个数. 当n小于1,000,000时候,n/φ(n)最大值时候的n. 欧拉函数维基百科链接 这里的是p是n ...

  2. 欧拉工程第70题:Totient permutation

    题目链接 和上面几题差不多的 Euler's Totient function, φ(n) [sometimes called the phi function]:小于等于n的数并且和n是互质的数的个 ...

  3. 欧拉工程第51题:Prime digit replacements

    题目链接 题目: 通过置换*3的第一位得到的9个数中,有六个是质数:13,23,43,53,73和83. 通过用同样的数字置换56**3的第三位和第四位,这个五位数是第一个能够得到七个质数的数字,得到 ...

  4. 欧拉工程第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 ...

  5. 欧拉工程第66题:Diophantine equation

    题目链接 脑补知识:佩尔方差 上面说的貌似很明白,最小的i,对应最小的解 然而我理解成,一个循环的解了,然后就是搞不对,后来,仔细看+手工推导发现了问题.i从0开始变量,知道第一个满足等式的解就是最小 ...

  6. 欧拉工程第65题:Convergents of e

    题目链接 现在做这个题目真是千万只草泥马在心中路过 这个与上面一题差不多 这个题目是求e的第100个分数表达式中分子的各位数之和 What is most surprising is that the ...

  7. 欧拉工程第56题:Powerful digit sum

    题目链接   Java程序 package projecteuler51to60; import java.math.BigInteger; import java.util.Iterator; im ...

  8. 欧拉工程第55题:Lychrel numbers

    package projecteuler51to60; import java.math.BigInteger; import java.util.Iterator; import java.util ...

  9. 欧拉工程第54题:Poker hands

    package projecteuler51to60; import java.awt.peer.SystemTrayPeer; import java.io.BufferedReader; impo ...

随机推荐

  1. matlab求距一个数最近的奇(偶)数

    int_a = floor(a);minEven = int_a+mod(int_a,2); %最近偶数minOdd = int_a+1-mod(int_a,2); %最近奇数

  2. Mac下的常用Shell命令

    今天介绍一下在Mac的终端中一些常用的Shell命令: 1.查看当前工作目录的完整路径 pwd (pwd的原意是:print work directiory,而不是密码password的意思,呵呵) ...

  3. C# 或 JQuery导出Excel

    首先要添加NPOI.dll文件 然后添加类:NPOIHelper.cs using System; using System.Data; using System.Configuration; usi ...

  4. Java_Swing实现小球沿正弦曲线运动的代码

    1 package zuidaimapack_1; import java.awt.*; import javax.swing.*; /** *Java_Swing实现小球沿正弦曲线运动的代码 * @ ...

  5. 菜鸟搭建Android环境~~~~绝对靠谱

    因为要测试移动设备.搭建了一下Android环境 这是菜鸟级别的安装 因为sdk版本,eclipse版本,adt版本各自有版本要求,所以我选择都去官网下载新版本,这样总不会出现版本兼容性问题了吧~~ ...

  6. HDU 5151 Sit sit sit 区间dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5151 题解: 有n个椅子,编号为1到n. 现在有n个同学,编号为1到n,从第一个同学开始选择要坐的位 ...

  7. Applicationpoolidentity 好有趣哦

    前言: 在服务器上搭建一个网站 Windows Server2008 R2 +IIS7. 应用程序池默认选择ApplicationPoolIdentity.为了适应分布式需求,所以将SqlServer ...

  8. 一个包的libevent流程

    //一个发包的流程 第一个包就是客户端的心跳包,现在加了版本的包 再来看看这个发包打包过程,过程坚持,但理解费劲 void NGP::OnliveTimer()//客户端心跳,5s发一次 { Send ...

  9. 查看Centos系统信息命令

    linux命令行具有强大的功能,我们安装vps后,首先应该知道系统信息,查看这些信息,你会发现Linux命令很简单,你可以按照下面的命令练习. linux系统信息 # uname -a # 查看内核/ ...

  10. ios 图片转视频

    转自:http://blog.iosxcode4.com/archives/160 用到的FrameWork有: MediaPlayer.framework,QuartzCore.framework, ...