欧拉工程第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 ...
随机推荐
- 横屏下的ImagePickerController
Try this way.... As per Apple Document, ImagePicker Controller never Rotate in Landscape mode. You h ...
- 学习jax-ws(一)
1.生成文件时提示class not find ,需要加个cp .,这样就行了 E:\mylearn\learn_webservice\learnJax-ws\bin>wsgen -cp . w ...
- 用vs2013编译lua源码方法
1.下载lua源码:lua-5.2.3.tar.gz,解压 2.用vs2013建立一个win32工程: 1)下载后解压到一个目录下,这里假设解压到 F:\lua-5.2.3 注意下载的版本,如果是 ...
- 基于.net mvc的校友录(五、web.config对的配置以及filter实现的权限控制)
web.config配置文件 此文件是整个系统的配置中心,它告诉iis服务器本网站需要哪些运行时环境,需要哪些环境,将要进行哪些操作,开发人员也会将一个常量性的数据放在此配置中,以备系统全局调用.此文 ...
- 电梯调度--c++--软件工程
一.设计思路 (1)将乘客要去的楼层数存起来. (2)假设yi为乘客要爬楼层数之和,yi=n1*|(n1-ni)|+n2*|(n2-ni)|+..+n18*|(n18-ni)| (3)比较y1到y18 ...
- adb 连接时 device offline
继上一篇博文,会发现最后图片上 adb连接时候提示device offline 以下三种方法可以试一下~我是试到最后一种才成功 1.重启手机 2.adb kill-server adb star ...
- js分页
今天看了下妙味课堂的教程,写了下关于分页的js代码,写完的感觉就是有点小麻烦,需要很多if判断,思路要清晰 点击预览:http://peng666.github.io/blogs/page <! ...
- git创建和删除远程分支
问题描述: 使用git创建和删除远程分支 问题解决: (1)git创建本地分支 注: 如上所示,使用命令 git branch -a ...
- 【BZOJ】【1449】【JSOI2009】球队收益
网络流/费用流/二分图最小权匹配 题解:http://blog.csdn.net/huzecong/article/details/9119741 太神了!由于一赢一输不好建图,就先假设全部都输,再将 ...
- Binary Indexed Tree 2D 分类: ACM TYPE 2014-09-01 08:40 95人阅读 评论(0) 收藏
#include <cstdio> #include <cstdlib> #include <climits> #include <cstring> # ...