sgu 108 Self-numbers 2】的更多相关文章

SGU 108 Self-numbers 2 Problem's Link Mean: 略有这样一种数字:对于任意正整数n,定义d(n)为n加上n的各个位上的数字(d是数字的意思,Kaprekar发明的一个术语).如:d(75) = 75 + 7 + 5 = 87.给定任意正整数n,你可以构建出无限的整数递增:n, d(n), d(d(n)), d(d(d(n))), ……举个例子,你从33开始,那么下一个数就是33 + 3 + 3 = 39, 再下一个就是39 + 3 + 9 = 51, 接着…
翻译:引自 http://www.cnblogs.com/yylogo/archive/2011/06/09/SGU-108.html 在1949年印度的数学假D.R. Kaprekar发现了一种叫做self-number的经典数字,对于任意正整数n,定义d(n)为n加上n的各个位上的数字(d是数字的意思,Kaprekar发明的一个术语).如:d(75) = 75 + 7 + 5 = 87.给定任意正整数n,你可以构建出无限的整数递增:n, d(n), d(d(n)), d(d(d(n))),…
这道题难在 hash 上, 求出答案很简单, 关键是我们如何标记, 由于 某个数变换后最多比原数多63 所以我们只需开一个63的bool数组就可以了! 同时注意一下, 可能会有相同的询问. 我为了防止给的询问不是有序的,还排了一边序. #include <cstdio> #include <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #include &…
时间限制:0.5s 空间限制:6M 题意:         在b(2<b<36)进制中,找到所有长度为n(0<n<2000)的自守数k,满足k^2%b^n=k,字典序输出.         如 十进制中     9376^2 = 87909376   后面4位数都是9376. Solution:                可以发现长度为n的满足要求的数中,其后n-1位也是自守数.                这样的数是很稀疏的,可以直接从n=1的情况开始搜索.当找到长度为n的…
题意:这样的数有几个? 模仿筛法就能解出,但是内存不够.这就需要重复利用数组,用100大小的数组,所有的数对100取模.对于一个数,比如71,就在arr[78]=71记录下来.到78时,检查78-71<90.说明近期有数能产生78.而178对100取模也是78,如果后来(比178小90以内的数)没有数能产生78.那么178-arr[178]将>90就是符合条件的.而比178小90以内的数只能产生178,不可能产生78或者278. #include <iostream> #inclu…
time limit per test 3 seconds memory limit per test 512 megabytes input standard input output standard output You are given an undirected graph with weighted edges. The length of some path between two vertices is the bitwise xor of weights of all edg…
Shortest Path Problem? You are given an undirected graph with weighted edges. The length of some path between two vertices is the bitwise xor of weights of all edges belonging to this path (if some edge is traversed more than once, then it is include…
You are given an undirected graph with weighted edges. The length of some path between two vertices is the bitwise xor of weights of all edges belonging to this path (if some edge is traversed more than once, then it is included in bitwise xor the sa…
169.Numbers Let us call P(n) - the product of all digits of number n (in decimal notation). For example, P(1243)=1*2*4*3=24; P(198501243)=0. Let us call n to be a good number, if (p(n)<>0) and (n mod P(n)=0). Let us call n to be a perfect number, if…
题意: 定义一个具有2n位的正整数,其前n位之和与后n位之和相等,则为lucky数.给定一个区间,问有多少个正数可以通过修改某一位数从而变成lucky数?注意不能含前导0. 思路: 我的想法是记录那些非lucky数,再想办法来统计,后来发现有点行不通,无法知道其前后部之和是否相等.如果记录lucky数,然后通过统计每个位上的数来变成lucky数,这更麻烦,因为会重复统计,比如11和22是lucky数,而21可以通过修改1位来变成lucky数,被统计了两次. 学习了前辈的方法,也强迫一下自己别人的…