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【组合数】相关推荐

  1. 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 ...

  2. Project Euler Problem 104 Pandigital Fibonacci ends

    Pandigital Fibonacci ends Problem 104 The Fibonacci sequence is defined by the recurrence relation: ...

  3. Project Euler Problem 66

    Problem 66 Consider quadratic Diophantine equations of the form: x2 – Dy2 = 1 For example, when D=13 ...

  4. Project Euler Problem 27小结

    Project Euler上有很多有意思的问题,刚做到第27题,对这个问题做个小结. Problem 27: Euler有一个著名的方程n^2+n+41,当n=0到39时,方程结果均为质数.如今人们用 ...

  5. Project Euler Problem 27 Quadratic primes

    Quadratic primes Problem 27 Euler discovered the remarkable quadratic formula: n2+n+41 It turns out ...

  6. 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 ...

  7. Project Euler Problem 25 1000-digit Fibonacci number

    1000-digit Fibonacci number Problem 25 The Fibonacci sequence is defined by the recurrence relation: ...

  8. Project Euler Problem 14 Longest Collatz sequence

    Longest Collatz sequence Problem 14 The following iterative sequence is defined for the set of posit ...

  9. Project Euler Problem 48: Self powers

    Self powers Problem 48 The series, 11 + 22 + 33 + ... + 1010 = 10405071317. Find the last ten digits ...

最新文章

  1. RecycleView Layout 详解
  2. 浏览器卡怎么办_SD卡无法格式化怎么修复?简单修复方法介绍
  3. SQL Server 用表中已有数据造数据
  4. 泡泡玛特就“女性面试需填生育计划”一事致歉 称将积极改进
  5. python跳过本次循环_Python的一些格式与逻辑控制语句
  6. 如何获取集合里面的下标_怎样获取list集合中的最后一个对象中的值
  7. soft215@163.com,销售工程造价,建筑,工控,模拟分析,财务等商业版软件︻◣
  8. 华为手机fastboot解锁
  9. 慎用某60软件清理垃圾,导致三星SSD T5不识别了,折腾了一下午,终于弄好了
  10. 【神经网络分类器】(三)深度学习发展史——从深度信念网络到AlexNet
  11. i78700k配什么显卡好_2K分辨率极致吃鸡 i7-8700K配GTX1070Ti吃鸡配置推荐 (全文)
  12. 国产数据库-达梦数据库安装
  13. 【原创】MATLAB汽车制动防抱死模型ABS模型
  14. Spring Boot和jOOQ整合
  15. 八零后月薪56K老程序员感慨人生的起起伏伏,跳槽居然没地方让我跳!
  16. Load balancer 负载均衡
  17. WIN7登陆界面去掉下面windows 7 旗舰版
  18. 动图之一个圆绕另一个圆转动
  19. 世界上最会撒谎的两类人
  20. 混合式开发APP项目——幸福到App

热门文章

  1. Mybatis insert、update 、delete返回值
  2. 【资源分享】一周整理的,这是价值10W的32个Python项目!
  3. SpringFramework、SpringBoot、SpringCloud的区别
  4. c语言杨辉三角的实验心得体会范文,大学生实验心得体会精选范文5篇
  5. Arduino I2C任意更换SDA SCL GPIO引脚
  6. java监听器(Listener)统计在线人数
  7. vue 使用百度 API 实现图像识别
  8. Python快速入门 满满都是干货!
  9. HTML span 标签 的详细用法
  10. 从“零”开始的C语言