HDU 2274 Magic WisKey
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2274
Magic WisKey
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 568 Accepted Submission(s):
323
little WisKey’s heart and he wants to learn some magic to make himself
stronger.
One day, he met a cowman named LinLe. Linle is very nice, he told
little WisKey the mysteries of magic. Now, little WisKey began to perform the
magic to you.
“Hello, Everybody. I have five decimal numbers named a, b, c,
d, e, (0 <= a, b, c, d, e <= 9) and I rearranged them, and then combined
them into a number, for example <a, b, c, d, e> = a*10000 + b*1000 + c*100
+ d*10 + e*1. You know the number of permutations is 5! = 120. So you have 120
numbers in your hands, you can pick a number N from the 120 numbers and
calculate the sum S of remain 119 numbers. AHA~, If you tell me the S, I can
guess the N~!”
It’s easy? Okay, you can challenge this.
file.
N with 5 digits, including the leading zeros, one line per case.
I promise
every case have one solution at least. If have many N, please output them from
small to large in one line, separate them with a blank space.
求五位数全排列之和的方法:假设五个数字分别是a,b,c,d,e。首先考虑a,a在万位上会出现4!次,千位上也会出现4!次,百位十位个位同理,所以a出现的每个地方总和为a*4!*(10000+1000+100+10+1)。b,c,d,e与a类似。所以总和为(a+b+c+d+e)*4!*11111。
AC代码:
#include<stdio.h>
#include<string.h>
int a[],s[],sum;
int main()
{
for(int i=;i<=;i++) { //先打表
int t=i,k=,sum;
while(t>) {
a[k++]=t%;
t/=;
}
int tmp=;
for(int j=;j<k;j++)
tmp+=a[j];
s[i]=tmp**-i;
}
while(~scanf("%d",&sum)) { //直接查询
for(int i=;i<=;i++)
if(sum==s[i]) printf("%05d\n",i);
}
return ;
}
HDU 2274 Magic WisKey的更多相关文章
- HDU 1153 magic bitstrings(读题+)
hdu 1153 magic bitstrings 题目大意 一个质数p,现在让你求一个p-1长度的“01魔法串”.关于这个魔法串是这么定义的: 我们现在把这个串经过一段处理变成一个长宽均为p ...
- hdu 4605 Magic Ball Game
http://acm.hdu.edu.cn/showproblem.php?pid=4605 可以离线求解 把所以可能出现的 magic ball 放在一个数组里(去重),从小到大排列 先不考虑特殊 ...
- [搜索] hdu 4016 Magic Bitwise And Operation
主题链接: http://acm.hdu.edu.cn/showproblem.php?pid=4016 Magic Bitwise And Operation Time Limit: 6000/30 ...
- hdu A Magic Lamp
http://acm.hdu.edu.cn/showproblem.php?pid=3183 A Magic Lamp Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 4605 Magic Ball Game(可持续化线段树,树状数组,离散化)
Magic Ball Game Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- HDU 4602 Magic Ball Game(离线处理,树状数组,dfs)
Magic Ball Game Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 【树形动规】HDU 5834 Magic boy Bi Luo with his excited tree
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5834 题目大意: 一棵N个点的有根树,每个节点有价值ci,每条树边有费用di,节点的值只能取一次,边 ...
- HDU 4605 Magic Ball Game (在线主席树|| 离线 线段树)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 题意:给出一棵二叉树,每个结点孩子数目为0或者2. ...
- HDU 4323 Magic Number(编辑距离DP)
http://acm.hdu.edu.cn/showproblem.php?pid=4323 题意: 给出n个串和m次询问,每个询问给出一个串和改变次数上限,在不超过这个上限的情况下,n个串中有多少个 ...
随机推荐
- 为ssh增加选项
在使用ssh的时候,可以看到ssh有很多功能,什么-o , -e等等.如下图 需求,想要给ssh增加一个参数的功能.比如说我现在的需求就是执行ssh的时候可以增加一个选项,给我每次ssh的操作搭一个标 ...
- 如何设置WIN10任务栏
1.鼠标右键点击任务栏 然后点击锁定任务栏,去掉前面的钩 2.然后鼠标右击任务栏 选择工具栏 点击新建工具栏 3.打开后点击新建文件夹,可以重命名,然后选择刚才新建的文件夹 4.此时任务栏就有了 5. ...
- velocity常用语句速查表
velocity常用语句 * 变量定义 #set($directoryRoot = "www" ) * #if($!list.size() != 0) //判断list不为空 #f ...
- 程序设计入门——C语言 第1周编程练习 1逆序的三位数(5分)
第1周编程练习 查看帮助 返回 第1周编程练习题,直到课程结束之前随时可以来做.在自己的IDE或编辑器中完成作业后,将源代码的全部内容拷贝.粘贴到题目的代码区,就可以提交,然后可以查看在线编译和运 ...
- Deep Learning 13_深度学习UFLDL教程:Independent Component Analysis_Exercise(斯坦福大学深度学习教程)
前言 理论知识:UFLDL教程.Deep learning:三十三(ICA模型).Deep learning:三十九(ICA模型练习) 实验环境:win7, matlab2015b,16G内存,2T机 ...
- 如何让IE8的菜单栏调到最上方
如何让IE8的菜单栏调到最上方 运行gpedit.msc,在"用户配置"/"管理模板"/"Windows Components"/" ...
- Authentication和Authorization的区别
搞不太清楚Authentication和Authorization的区别,在网上搜了一下,lucky16的一篇文章讲的通俗,看了就懂,记录下来: 你要登机,你需要出示你的身份证和机票,身份证是为了证明 ...
- SQL SERVER 查看所有index
WITH INDEX_TABLE AS( as DatabaseID, o.name AS TableName, c.name AS ColumnName,ic.index_id,i.type_des ...
- SG函数 专题练习
[hdu1536][poj2960]S-Nim 题意 题意就是给出一个数组h,为每次可以取石子的数目. 然后给你n堆石子每堆si.求解先手能不能赢? 分析 根据\(h\)数组预处理出\(sg[i]\) ...
- @Scheduled 注解
Spring配置文件xmlns加入 <!---加入:xmlns:task="http://www.springframework.org/schema/task"--> ...