本文章学习于 acdreamers

二项式定理:

这个题因为n太大了,所以用java大数写

在递归的时候 记忆化一下

import java.math.*;
import java.util.*;
public class Main {public static final int N = 105;public static final BigInteger FLAG = (BigInteger.ZERO).subtract(BigInteger.ONE); // -1public static BigInteger[][] C = new BigInteger[N][N];public static BigInteger[] ans = new BigInteger[N];public static void Init(){for(int i = 0; i < N; i++){C[i][0] = C[i][i] = BigInteger.ONE;if(i == 0){continue;}for(int j = 1; j < i; j++){C[i][j] = C[i-1][j].add(C[i-1][j-1]);}}}public static BigInteger slove(BigInteger n, int k){if(ans[k].compareTo(FLAG) != 0){return ans[k];}if(k == 1){ans[k] = ((n.add(BigInteger.ONE)).multiply(n)).divide(BigInteger.valueOf(2));return ans[k];}BigInteger temp = BigInteger.ONE;for(int i = 0; i < k + 1; i++){temp = temp.multiply(n.add(BigInteger.ONE));}temp = temp.subtract(n.add(BigInteger.ONE));BigInteger sum = BigInteger.ZERO;for(int i = 1; i < k; i++){BigInteger t = C[k+1][i+1].multiply(slove(n, k - i));sum = sum.add(t);}ans[k] = (temp.subtract(sum)).divide(BigInteger.valueOf(k+1));return ans[k];}public static void main(String[] args) {Init();Scanner cin = new Scanner(System.in);while (cin.hasNext()){BigInteger n = cin.nextBigInteger();int k = cin.nextInt();for(int i = 0; i < N; i++){ans[i] = FLAG;}System.out.println(slove(n, k));}}
}

ZOJ - 2865 A very easy task相关推荐

  1. Easy Task —— 强大易用的分布式任务调度平台

    Easy Task 概述 github:https://github.com/cehome-com/easy-task 简单易用的分布式任务调度平台.来源于淘宝彩票调度平台,并先后在淘宝内容抓取平台和 ...

  2. ZOJ 2913 Bus Pass (近期的最远BFS HDU2377)

    题意  在全部城市中找一个中心满足这个中心到全部公交网站距离的最大值最小 输出最小距离和满足最小距离编号最小的中心 最基础的BFS  对每一个公交网站BFS  dis[i]表示编号为i的点到全部公交网 ...

  3. A Collection of 100+ Writing Task 2 Essays for IELTS

    EDITION 2019 A Collection of 100+ Writing Task 2 Essays IELTS ESSAYS FROM EXAMINERS VERSION 3.0 OREM ...

  4. 论文阅读《Expert Training Task Hardness Aware Meta-Learning for Few-Shot Classification》

    原文链接:https://arxiv.org/abs/2007.06240 摘要 在一些深度神经网络的优化工作中发现,训练数据的顺序对于分类器的性能有一定影响,合理地安排顺序使分类器更快.更准.受此启 ...

  5. ZOJ 1090 The Circumference of the Circle(计算三角形的外接圆)

    提交地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1090 这是我最喜欢做的题之一,因为这种题我感觉 做一遍以后就会了 ...

  6. TYUT-A专题题解(一)

    TYUT-A专题题解(一) 01A Ad Hoc UVA353 LA5247 Pesky Palindromes[回文] - 海岛Blog - CSDN博客 UVA947 Master Mind He ...

  7. 已知圆上的三个点求此圆的周长

    The Circumference of the Circle 本题在ZOJ上题号是1090,在POJ上是2242.题目描述如下: Description To calculate the circu ...

  8. html:漂亮的原生表格_HTML表格:关于它们的所有知识

    html:漂亮的原生表格 by Alexander Gilmanov 亚历山大·吉尔马诺夫(Alexander Gilmanov) HTML表格:关于它们的所有知识 (HTML Tables: All ...

  9. stackoverflow_StackOverflow帐户如何确保您在公认的开发人员表格中占有一席之地

    stackoverflow by Melchor Tatlonghari 由Melchor Tatlonghari StackOverflow帐户如何确保您在公认的开发人员表格中占有一席之地 (How ...

  10. 如何使用React提前三天计划

    by Mohit Jain 由Mohit Jain 如何使用React提前三天计划 (How you can plan three days ahead with React) Today we'll ...

最新文章

  1. windows10+Python3-如何安装numpy和matplotlib包
  2. websocketd 实现浏览器查看服务器实时日志
  3. 【bzoj3884】上帝与集合的正确用法 扩展欧拉定理
  4. MAC apache配置
  5. Python中各进制间的转换
  6. 代码命名,代码里的命名规则:错误的和正确的对比 命名方法总结 “自我描述的源代码”用代码表达出你的思想,让其他人通过代码能明白你的意图。...
  7. Cache占用过多内存导致Linux系统内存不足问题排查
  8. sql 两个 in_SQL基础知识——IN运算符
  9. 第32月第8天 打包 Framework 时使用 CocoaPods 引入第三方库的方法
  10. 【Java】输出10-1000中间既能被3整除又能被7整除的数
  11. 10_文件包含漏洞(属于任意代码执行)
  12. python传递参数 调用c++ 传递vector_python调用c++传递数组的实例
  13. ultraedit比较文件没反应_计算机二级虚拟机安装视频和虚拟机文件
  14. 【架构解密】第六章 深入解析分布式存储
  15. Linux高可用集群搭建
  16. matlab 矩阵 三维矩阵相乘,将三维矩阵与二维矩阵相乘
  17. Cherno_游戏引擎系列教程(1):1~16
  18. 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 HDU - 2191(特殊01背包)
  19. mysql explain type_MySQL explain type详解
  20. 全球人口密度大致分布

热门文章

  1. 图像处理库Pillow
  2. 快速部署简单私有云CloudStack(下)
  3. linux虚拟机ping通主机
  4. python 写一个scheme解释器(一)
  5. [导入]新手入门 Fedora Linux 7系统的安装指南
  6. 煤矿行业设备管理系统
  7. STemWin5.22在STM32F103上的移植步骤
  8. 深入了解absolute
  9. 左边导航条动态增加或缩短高度以及放大缩小问题的解决方法
  10. SPOJ 196 动态规划