#include<iostream>
#include<vector>
#include<algorithm>
using namespace std; int cnk(int n, int k)
{
int a,b;
a=b=;
for(int i=; i<k; i++)
{
a *= n--;
b *= (i+);
} return a/b;
} int arrange_calculate(int *a)
{
int n=;
int ans=;
for(int i=; i<; i++)
n += a[i]; for(int i=; i<; i++)
if(a[i]>)
{
ans *= cnk(n, a[i]);
n -= a[i];
}
return ans;
} int main()
{
int T,N;
cin>>T;
for(int i=; i<T; i++)
{
cin>>N;
int a[]={}; //记录N中1-9出现的次数
int total=; //记录N的各个位上的数之和
int count=; //保存N有多少位,1表示个位,2表示十位,3表示百位,以此类推
while(N)
{
int temp = N%;
total += temp;
a[temp]++;
N /=;
count++;
}
int arrangeNum = arrange_calculate(a); int s=;
for(int j=; j<count; j++)
{
s += total;
total *= ;
} int ans;
if(arrangeNum<count) //此时输入的N一定是22222这种各个位上的数都相同的这种类型的数
ans = s/count;
else
ans = (int)(s * (arrangeNum*1.0/count)); //arrangeNum不一定是count的整数倍,比如2233对应的count=4,arrangeNum=6 cout<<ans<<endl; }
return ;
}

Problem 1183 - 排列的更多相关文章

  1. UVALive 6909 Kevin's Problem 数学排列组合

    Kevin's Problem 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid ...

  2. Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 离散化 排列组合

    E. Mike and Geometry Problem 题目连接: http://www.codeforces.com/contest/689/problem/E Description Mike ...

  3. 九度OJ 1183 守形数 (模拟)

    题目1183:守形数 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2663 解决:1424 题目描写叙述: 守形数是这样一种整数.它的平方的低位部分等于它本身. 比方25的平方是625. ...

  4. 九度OJ 1183:守形数 (数字特性)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3815 解决:2005 题目描述: 守形数是这样一种整数,它的平方的低位部分等于它本身. 比如25的平方是625,低位部分是25,因此25是 ...

  5. [codevs 1183][泥泞的道路(二分+spfa)

    题目:http://dev.codevs.cn/problem/1183/ 分析:这个和最优比率生成树很像,都可以二分答案的,只不过判定方面一个是求是否有最短路径,一个是求是否有生成树.假设等待判定的 ...

  6. lintcode Permutation Index

    题目:http://www.lintcode.com/zh-cn/problem/permutation-index/ 排列序号 给出一个不含重复数字的排列,求这些数字的所有排列按字典序排序后该排列的 ...

  7. 【Codevs1183】泥泞的道路

    Position: http://codevs.cn/problem/1183/ List Codevs1183 泥泞的道路 List Description Input Output Sample ...

  8. ACDream - Xor pairs

    先上题目: Xor pairs Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Sub ...

  9. Codeforcs 1183B Equalize Prices

    题目链接:codeforces.com/problemset/problem/1183/B 题意:给你 n 个数,每个数能在k范围内上下浮动,求能否使所有数相等,能输出相等的最大值,不能输出 -1. ...

随机推荐

  1. UVA 10561 Treblecross(博弈论)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=32209 [思路] 博弈论. 根据X分布划分禁区,每个可以放置的块为 ...

  2. C++经典KMP算法的实现

    #include <iostream> #include <algorithm> #include <vector> #include <string> ...

  3. openStack 瓶颈测试

  4. (三)phpcms之文件目录

    刚刚接触phpcms,先从它的目录结构说起. 如下图所示,是phpcms的主目录结构: 其中api是接口目录,这个接口不是很明白.大概其是把别的内容加入进来,比如论坛啊什么的. caches是缓存文件 ...

  5. 【Android - MD】之NavigationView的使用

    NavigationView是Android 5.0新特性--Material Design中的一个布局控件,可以结合DrawerLayout使用,让侧滑菜单变得更加美观(可以添加头部布局). Nav ...

  6. spring 自定义schema

    扩展schema,定义自己的bean属性..不错! 主要: 1,定义META-INF下.xsd文件,这里是people.xsd;定义spring.handlers;定义spring.schemas 2 ...

  7. jquery+正則表達式验证邮箱格式的样例

    js: $("#email").blur(function(){ //获取id相应的元素的值,去掉其左右的空格 var email = $.trim($('#email').val ...

  8. [React + Mobx] Mobx and React intro: syncing the UI with the app state using observable and observer

    Applications are driven by state. Many things, like the user interface, should always be consistent ...

  9. 关于PHP定时执行任务的实现(转)

    PHP在这方面应该说是比较弱,如果只用php去实现可以如下: <?php ignore_user_abort();//关闭浏览器后,继续执行php代码 set_time_limit(0);//程 ...

  10. Instruction (hdu 5083)

    Instruction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...