欧拉工程第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 ...
随机推荐
- Window7上搭建symfony开发环境(PEAR)
http://blog.csdn.net/kunshan_shenbin/article/details/7162243 1. 更新PEAR 进入PHP所在目录,找到go-pear.bat并双击. 一 ...
- UIView Programming Guide学习笔记
|View |Creating and Configuring View Objects |Creating and Managing a View Hierarchy |Adjusting the ...
- 转:CentOS 7 安装Nginx
一.准备工作: 1.安装必备工具: ? 1 2 3 $ yum -y install gcc gcc-c++ autoconf automake $ yum -y install zlib zli ...
- html a 链接
1.链接元素 文本.图像.热区 2.标记 描述性文字 target窗口形式 _self:在自身窗口打开(默认) _blank:在新窗口打开 _parent:在父窗口打开 _top:在顶窗口打开 框架或 ...
- skill-判断浏览器
判断是ie浏览器还是火狐等标准浏览器 var ie=!+"\v1"; 因为ie浏览器不支持\v,也就是水平制表符,所以"\"符号会被忽略,前面的+号是把&quo ...
- ABAP自定义类的构造方法
REPORT ytest_011. *----------------------------------------------------------------------* * CLASS z ...
- html转义函数
public static String filter(String message) { if (message == null) return (null); char content[] = n ...
- 文件操作的openmode
C中文件的openmode如下: r 只读 为输入打开一个文本文件 w 只写 为输出打开一个文本文件 a 追加 向文本文件尾添加数据 rb 只读 为输入打开一个二进制文件 wb 只写 为输出打开一个二 ...
- android开发,关于android app实现静默安装自己(系统签名)
产品需求,木有办法.android系统是跟厂商定制的,保证系统开机就运行我们的app,并且实现自己静默安装,完全自动化,无需人工操作. 网上有很多办法, 1.要么要通过android 源码拿到密钥文件 ...
- Entity Framework 学习之--Ling to entity实现分页
最近用MVC做的一个项目涉及到分页,中间用了entity framework来查数据库,不用直接写sql语句,方便了很多. 一般分页的思路是获得两个变量的值: 1.一共有多少条记录 totalCoun ...