Project Euler Problem 53: Combinatoric selections【组合数】
PE其他解题报告请参考这里,本题答案在留言首条
Combinatoric selections
Problem 53
There are exactly ten ways of selecting three from five, 123451234512345:
123,124,125,134,135,145,234,235,245,and345123, 124, 125, 134, 135, 145, 234, 235, 245, and 345123,124,125,134,135,145,234,235,245,and345
In combinatorics, we use the notation, 5C3=105C_3 = 105C3=10.
In general,
nCr=n!r!n!−r!nC_r = \frac {n!r!}{n!−r!}nCr=n!−r!n!r!,where r ≤ n, n! = n×(n−1)×…×3×2×1, and 0! = 1.
It is not until n = 23, that a value exceeds one-million: 23C10 = 1144066.
How many, not necessarily distinct, values of nCr, for 1 ≤ n ≤ 100, are greater than one-million?
题意:
让你求组合数CnmC_n^mCnm 1 <= n <= 100, 1 <= m <= n,大于一百万的组合数的个数
分析:
根据组合数的性质,暴力跑就行,如果大于一百万,就赋值1000001,这样保证不会爆int
参考代码
#include<bits/stdc++.h>using namespace std;int c[111][111];void init() {c[0][0] = 1;int cnt = 0;for (int i = 1; i <= 100; i++) {for (int j = 0; j <= i; j++) {if (j == 0 || j == i) c[i][j] = 1;else {int t = c[i - 1][j] + c[i - 1][j - 1];if (t > 1000000) c[i][j] = (int)(1e6) + 1, cnt++;else c[i][j] = t;}}}cout << cnt << endl;
}int main(){init();return 0;
}```***阅读好习惯:点赞 + 收藏~***
Project Euler Problem 53: Combinatoric selections【组合数】相关推荐
- Project Euler:Problem 53 Combinatoric selections
There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 2 ...
- Project Euler Problem 104 Pandigital Fibonacci ends
Pandigital Fibonacci ends Problem 104 The Fibonacci sequence is defined by the recurrence relation: ...
- Project Euler Problem 66
Problem 66 Consider quadratic Diophantine equations of the form: x2 – Dy2 = 1 For example, when D=13 ...
- Project Euler Problem 27小结
Project Euler上有很多有意思的问题,刚做到第27题,对这个问题做个小结. Problem 27: Euler有一个著名的方程n^2+n+41,当n=0到39时,方程结果均为质数.如今人们用 ...
- Project Euler Problem 27 Quadratic primes
Quadratic primes Problem 27 Euler discovered the remarkable quadratic formula: n2+n+41 It turns out ...
- Project Euler Problem 92 Square digit chains
Square digit chains Problem 92 A number chain is created by continuously adding the square of the di ...
- Project Euler Problem 25 1000-digit Fibonacci number
1000-digit Fibonacci number Problem 25 The Fibonacci sequence is defined by the recurrence relation: ...
- Project Euler Problem 14 Longest Collatz sequence
Longest Collatz sequence Problem 14 The following iterative sequence is defined for the set of posit ...
- Project Euler Problem 48: Self powers
Self powers Problem 48 The series, 11 + 22 + 33 + ... + 1010 = 10405071317. Find the last ten digits ...
最新文章
- RecycleView Layout 详解
- 浏览器卡怎么办_SD卡无法格式化怎么修复?简单修复方法介绍
- SQL Server 用表中已有数据造数据
- 泡泡玛特就“女性面试需填生育计划”一事致歉 称将积极改进
- python跳过本次循环_Python的一些格式与逻辑控制语句
- 如何获取集合里面的下标_怎样获取list集合中的最后一个对象中的值
- soft215@163.com,销售工程造价,建筑,工控,模拟分析,财务等商业版软件︻◣
- 华为手机fastboot解锁
- 慎用某60软件清理垃圾,导致三星SSD T5不识别了,折腾了一下午,终于弄好了
- 【神经网络分类器】(三)深度学习发展史——从深度信念网络到AlexNet
- i78700k配什么显卡好_2K分辨率极致吃鸡 i7-8700K配GTX1070Ti吃鸡配置推荐 (全文)
- 国产数据库-达梦数据库安装
- 【原创】MATLAB汽车制动防抱死模型ABS模型
- Spring Boot和jOOQ整合
- 八零后月薪56K老程序员感慨人生的起起伏伏,跳槽居然没地方让我跳!
- Load balancer 负载均衡
- WIN7登陆界面去掉下面windows 7 旗舰版
- 动图之一个圆绕另一个圆转动
- 世界上最会撒谎的两类人
- 混合式开发APP项目——幸福到App