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个串中有多少个 ...
随机推荐
- ASP.NET MVC view引入命名空间
两种方式:1,在cshtml中引入@using Admin.Models 2,在 Views 文件夹中的 Web.config 文件中添加引用如: <pages pageBaseType=&qu ...
- (转)QML代码与现有Qt UI代码整合
http://blog.csdn.net/henreash/article/details/7934315
- SVM学习(续)
SVM的文章可以看:http://www.cnblogs.com/charlesblc/p/6193867.html 有写的最好的文章来自:http://www.blogjava.net/zhenan ...
- Pycharm使用问题# 程序界面出现方框字符
Pycharm 程序至今依旧存在国际化问题,有时会出现程序界面有方框的现象,windows和linux好像都会出现,如下图:
- Caché数据库学习笔记(1)
目录: Caché的概念和基础知识 Caché数据库的安装 创建命名空间(namespace)和数据库(database) Documentation的使用 ===================== ...
- 转-浅谈HTTP中Get与Post的区别
Http定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST,PUT,DELETE.URL全称是资源描述符,我们可以这样认为:一个URL地址,它用于描述一个网络上的资源,而HTTP ...
- iOS基础篇(十五)——UIScrollView的基本用法
滚动视图(UIScrollView)通常用于显示内容尺寸大于屏幕尺寸的视图. 一.基本属性 1.CGSize contentSize :设置UIScrollView的滚动范围 2.CGPoint co ...
- Vmware workstation 10 NAT功能总是不正常的原因
原来运行一切正常的VMWARE WORKSTATION 10,突然出现NAT功能不能正常工作的情况. 表现是:如果将虚拟机的网卡设置为NAT模式,可以PING通网关及LAN内的主机,但是PING不通外 ...
- sC#进阶系列——WebApi 接口参数不再困惑:传参详解
原文:http://www.cnblogs.com/landeanfen/p/5337072.html 一.get请求 对于取数据,我们使用最多的应该就是get请求了吧.下面通过几个示例看看我们的ge ...
- HTTP 超时
TWinHTTPTimeouts = class(TPersistent) private FConnectTimeout, FReceiveTimeout, FSendTimeout: DWord; ...