题目链接

脑子抽了,看错题了,神奇的看成没有0了。主要问题把n个数插入m个相同的数,把m个数给分成1-m堆,然后插到n+1空里。

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <string>
  4. #include <cmath>
  5. #include <ctime>
  6. #include <cstdlib>
  7. #include <iostream>
  8. using namespace std;
  9. #define MOD 1000000
  10. #define LL long long
  11. LL c[][];
  12. int p[];
  13. int n;
  14. LL judge()
  15. {
  16. LL ans = ;
  17. int i,j,pre = ;
  18. LL temp;
  19. for(i = ;i < ;i ++)
  20. {
  21. if(p[i])
  22. {
  23. temp = ;
  24. for(j = ;j <= p[i];j ++)
  25. {
  26. temp += c[pre+][j]*c[p[i]-][j-];
  27. }
  28. ans *= temp;
  29. pre += p[i];
  30. }
  31. }
  32. return ans;
  33. }
  34. int main()
  35. {
  36. int i,j,num;
  37. LL ans,temp;
  38. for(i = ;i <= ;i ++)
  39. c[i][] = ;
  40. for(i = ;i <= ;i ++)
  41. {
  42. for(j = ;j <= ;j ++)
  43. c[i][j] = c[i-][j-] + c[i-][j];
  44. }
  45. while(cin>>n)
  46. {
  47. if(!n) break;
  48. memset(p,,sizeof(p));
  49. ans = ;
  50. for(i = ;i < n;i ++)
  51. {
  52. cin>>num;
  53. p[num] ++;
  54. }
  55. temp = ;
  56. for(i = ;i < n;i ++)
  57. {
  58. temp = temp* + ;
  59. }
  60. for(i = ;i < ;i ++)
  61. {
  62. if(p[i])
  63. {
  64. p[i] -- ;
  65. ans += i*temp*judge();
  66. p[i] ++;
  67. }
  68. }
  69. cout<<ans<<endl;
  70. }
  71. return ;
  72. }

UVA 11076 - Add Again(组合)的更多相关文章

  1. UVA 11076 Add Again 计算对答案的贡献+组合数学

    A pair of numbers has a unique LCM but a single number can be the LCM of more than one possiblepairs ...

  2. 【数论-数位统计】UVa 11076 - Add Again

    Add AgainInput: Standard Input Output: Standard Output Summation of sequence of integers is always a ...

  3. Uva 11076 Add Again (数论+组合数学)

    题意:给你N个数,求把他们的全排列加和为多少 思路:对于这道题,假设数字k1在第一位,然后求出剩下N-1位的排列数num1,我们就可以知道k1在第一位时 排列有多少种为kind1, 同理,假设数字k2 ...

  4. UVA 11076 Add Again

    题目链接:UVA-33478 题意为给定n个数,求这n个数能组成的所有不同的排列组成的数字的和. 思路:发现对于任意一个数字,其在每一位出现的次数是相同的.换言之,所有数字的每一位相加的和是相同的. ...

  5. UVa 11076 (有重元素的排列) Add Again

    n个可重复的元素的排列一共有 = All种,其中 假设这些数依次为ai,每种数字有mi个. 从右往左考虑第d位数(d≥0),第i个数字出现的次数为,那么这个数字对所求答案的贡献为 其实可以先一次求出个 ...

  6. Add Again UVA - 11076(排列之和)

    题意: 输入n个数字,求这些数字 所有全排列的和 (1<= n <= 12) 对于任意一个数字,其在每一位出现的次数是相同的    即所有数字的每一位相加的和是相同的. 因此可以等效为它们 ...

  7. 【NOIP合并果子】uva 10954 add all【贪心】——yhx

    Yup!! The problem name reects your task; just add a set of numbers. But you may feel yourselvesconde ...

  8. UVA 10954 Add All 哈夫曼编码

    题目链接: 题目 Add All Time Limit:3000MS Memory Limit:0KB 问题描述 Yup!! The problem name reflects your task; ...

  9. UVA - 11916 Emoogle Grid (组合计数+离散对数)

    假如有这样一道题目:要给一个M行N列的网格涂上K种颜色,其中有B个格子不用涂色,其他每个格子涂一种颜色,同一列中的上下两个相邻格子不能涂相同颜色.给出M,N,K和B个格子的位置,求出涂色方案总数除以1 ...

随机推荐

  1. Linux 标准目录结构

    初学Linux,首先需要弄清Linux 标准目录结构 / root --- 启动Linux时使用的一些核心文件.如操作系统内核.引导程序Grub等. home --- 存储普通用户的个人文件 ftp ...

  2. Python 小游戏 Bunny

    最近在学习Python,所以上网找了一个小程序练练手. 关于这款名为[Bunny]的小游戏,详细请看下面的链接: http://www.oschina.net/translate/beginning- ...

  3. 【131031】jsp学习实例 (2013-10-31 15:29:28)

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@ page language= ...

  4. 【openGL】画五角星

    #include "stdafx.h" #include <GL/glut.h> #include <stdlib.h> #include <math ...

  5. apache linux 安装

    sudo apt-get install zlib1g-dev 1.到官网下载,然后解压httpd-2.4.18.tar.gz 2.下载apr-1.5.2.tar.gz并解压    http://ar ...

  6. linux环境下libevent的使用

    step1:安装libevent yum install libevent step2: 代码入下: #include <sys/socket.h> #include <sys/ty ...

  7. php获取当前页面的完整url

    javascript实现: top.location.href 顶级窗口的地址 this.location.href 当前窗口的地址 php实现: //测试网址: http://localhost/b ...

  8. WebStorm中将Project分享到GitHub时报“Error Running Git”错误的解决办法

    错误信息 Cannot run program "git.exe":CreateProcess error=2,系统找不到指定的文件. 解决办法 从错误信息就可以知道,WebSto ...

  9. windows内核需要注意的

    修改windows内核函数 先屏蔽KdPrint 测试. Hook函数一律使用全局变量 妹的..KiTrap0E 修改.触发了已经断点.但是硬件断点Hook函数里只要使用KdPrint 就蓝屏

  10. LoadRunner关联函数的脚本实例--如何操作关联参数

    LoadRunner关联函数的脚本实例--如何操作关联参数 这几天一直在学习LoadRunner的VuGen编程,今天想对关联函数web_reg_save_param做详细的试验和研究: ~f6p q ...