题目链接

脑子抽了,看错题了,神奇的看成没有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(组合)的更多相关文章

  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. 苹果开发者账号申请时报错提示错误:Legal Entity Name

    he information you entered did not match your profile in the D&B database. Before submitting you ...

  2. Android浏览本地 API文档 + 解决页面加载慢的问题

    火狐浏览器安装离线浏览插件: 用浏览器打开index.html文件,你会发现加载的很慢,原因你懂的,为此,我们可以通过离线的方式 查看本地API文档,用火狐浏览器  +   Work Offline插 ...

  3. Java 8新特性

    Java 8版本最大的改进就是Lambda表达式,其目的是使Java更易于为多核处理器编写代码:其次,新加入的Nashorn引擎也使得Java程序可以和JavaScript代码互操作:再者,新的日期时 ...

  4. 檢查RAC狀態

    1.使用srvctl工具檢查RAC當前配置和狀態 $ srvctl config database -h Displays the configuration for the database. Us ...

  5. Runtime 类

    Runtime代表Java程序的运行时环境,每一个Java程序在运行时都有一个Runtime实例与之对应.Java程序通过它可以和运行时环境相连 1,和JVM进行交互,通知JVM进行垃圾回收等 2,获 ...

  6. easyui tree折叠

    标签 <div id="buildDiv" data-options="region:'center'" title="楼栋权限" s ...

  7. APP交互

    交互设计基本功!5个值得学习的APP交互方式http://www.uisdc.com/5-interactive-design-worth-learning 移动App交互设计10大趋势–你用到了吗? ...

  8. PHP isset()与empty()的使用区别详解(转)

    通过对PHP语言的学习,应该知道它是基于函数的一款HTML脚本语言.庞大的函数库支持着PHP语言功能的实现.下面我们为大家介绍有关PHP函数isset()与empty()的相关用法.     PHP的 ...

  9. DWZ分页、排序失效小结

    1. 在视图文件中与分页相关的代码段 <form id="pagerForm" method="post" action="w_list.htm ...

  10. HDU 4251 The Famous ICPC Team Again 主席树

    The Famous ICPC Team Again Problem Description   When Mr. B, Mr. G and Mr. M were preparing for the ...