UVA 11076 - Add Again(组合)
脑子抽了,看错题了,神奇的看成没有0了。主要问题把n个数插入m个相同的数,把m个数给分成1-m堆,然后插到n+1空里。
- #include <cstdio>
- #include <cstring>
- #include <string>
- #include <cmath>
- #include <ctime>
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- #define MOD 1000000
- #define LL long long
- LL c[][];
- int p[];
- int n;
- LL judge()
- {
- LL ans = ;
- int i,j,pre = ;
- LL temp;
- for(i = ;i < ;i ++)
- {
- if(p[i])
- {
- temp = ;
- for(j = ;j <= p[i];j ++)
- {
- temp += c[pre+][j]*c[p[i]-][j-];
- }
- ans *= temp;
- pre += p[i];
- }
- }
- return ans;
- }
- int main()
- {
- int i,j,num;
- LL ans,temp;
- for(i = ;i <= ;i ++)
- c[i][] = ;
- for(i = ;i <= ;i ++)
- {
- for(j = ;j <= ;j ++)
- c[i][j] = c[i-][j-] + c[i-][j];
- }
- while(cin>>n)
- {
- if(!n) break;
- memset(p,,sizeof(p));
- ans = ;
- for(i = ;i < n;i ++)
- {
- cin>>num;
- p[num] ++;
- }
- temp = ;
- for(i = ;i < n;i ++)
- {
- temp = temp* + ;
- }
- for(i = ;i < ;i ++)
- {
- if(p[i])
- {
- p[i] -- ;
- ans += i*temp*judge();
- p[i] ++;
- }
- }
- cout<<ans<<endl;
- }
- return ;
- }
UVA 11076 - Add Again(组合)的更多相关文章
- 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 ...
- 【数论-数位统计】UVa 11076 - Add Again
Add AgainInput: Standard Input Output: Standard Output Summation of sequence of integers is always a ...
- Uva 11076 Add Again (数论+组合数学)
题意:给你N个数,求把他们的全排列加和为多少 思路:对于这道题,假设数字k1在第一位,然后求出剩下N-1位的排列数num1,我们就可以知道k1在第一位时 排列有多少种为kind1, 同理,假设数字k2 ...
- UVA 11076 Add Again
题目链接:UVA-33478 题意为给定n个数,求这n个数能组成的所有不同的排列组成的数字的和. 思路:发现对于任意一个数字,其在每一位出现的次数是相同的.换言之,所有数字的每一位相加的和是相同的. ...
- UVa 11076 (有重元素的排列) Add Again
n个可重复的元素的排列一共有 = All种,其中 假设这些数依次为ai,每种数字有mi个. 从右往左考虑第d位数(d≥0),第i个数字出现的次数为,那么这个数字对所求答案的贡献为 其实可以先一次求出个 ...
- Add Again UVA - 11076(排列之和)
题意: 输入n个数字,求这些数字 所有全排列的和 (1<= n <= 12) 对于任意一个数字,其在每一位出现的次数是相同的 即所有数字的每一位相加的和是相同的. 因此可以等效为它们 ...
- 【NOIP合并果子】uva 10954 add all【贪心】——yhx
Yup!! The problem name reects your task; just add a set of numbers. But you may feel yourselvesconde ...
- UVA 10954 Add All 哈夫曼编码
题目链接: 题目 Add All Time Limit:3000MS Memory Limit:0KB 问题描述 Yup!! The problem name reflects your task; ...
- UVA - 11916 Emoogle Grid (组合计数+离散对数)
假如有这样一道题目:要给一个M行N列的网格涂上K种颜色,其中有B个格子不用涂色,其他每个格子涂一种颜色,同一列中的上下两个相邻格子不能涂相同颜色.给出M,N,K和B个格子的位置,求出涂色方案总数除以1 ...
随机推荐
- Linux 标准目录结构
初学Linux,首先需要弄清Linux 标准目录结构 / root --- 启动Linux时使用的一些核心文件.如操作系统内核.引导程序Grub等. home --- 存储普通用户的个人文件 ftp ...
- Python 小游戏 Bunny
最近在学习Python,所以上网找了一个小程序练练手. 关于这款名为[Bunny]的小游戏,详细请看下面的链接: http://www.oschina.net/translate/beginning- ...
- 【131031】jsp学习实例 (2013-10-31 15:29:28)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@ page language= ...
- 【openGL】画五角星
#include "stdafx.h" #include <GL/glut.h> #include <stdlib.h> #include <math ...
- apache linux 安装
sudo apt-get install zlib1g-dev 1.到官网下载,然后解压httpd-2.4.18.tar.gz 2.下载apr-1.5.2.tar.gz并解压 http://ar ...
- linux环境下libevent的使用
step1:安装libevent yum install libevent step2: 代码入下: #include <sys/socket.h> #include <sys/ty ...
- php获取当前页面的完整url
javascript实现: top.location.href 顶级窗口的地址 this.location.href 当前窗口的地址 php实现: //测试网址: http://localhost/b ...
- WebStorm中将Project分享到GitHub时报“Error Running Git”错误的解决办法
错误信息 Cannot run program "git.exe":CreateProcess error=2,系统找不到指定的文件. 解决办法 从错误信息就可以知道,WebSto ...
- windows内核需要注意的
修改windows内核函数 先屏蔽KdPrint 测试. Hook函数一律使用全局变量 妹的..KiTrap0E 修改.触发了已经断点.但是硬件断点Hook函数里只要使用KdPrint 就蓝屏
- LoadRunner关联函数的脚本实例--如何操作关联参数
LoadRunner关联函数的脚本实例--如何操作关联参数 这几天一直在学习LoadRunner的VuGen编程,今天想对关联函数web_reg_save_param做详细的试验和研究: ~f6p q ...