POJ 1023 The Fun Number System】的更多相关文章

Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight of the most significant bit (i.e., in position k-1), is -2^(k-1), and the weight of a bit in any position i (0 ≤ i < k-1) is 2^i. For example, a 3 bit…
题目来源:http://poj.org/problem?id=1023 题目大意: 有一种有趣的数字系统.类似于我们熟知的二进制,区别是每一位的权重有正有负.(低位至高位编号0->k,第i位的权值为2^i 或-2^i) 输入:第一行给定测试用例数.每个用例的第一行为一个正整数k(1<=k<=64),说明该二进制编码的位数长度.接下来一行是一个长度为k的字符串,仅有两种字母p和n,描述了该种编码格式中每一位的权重为正(p)还是为负(n).第三行为一个正整数,N(-2^23<=N<…
这是在看geeksforgeeks时看到的一道题,挺不错的,题目是 Given a number system with only 3 and 4. Find the nth number in the number system. First few numbers in the number system are: 3, 4, 33, 34, 43, 44, 333, 334, 343, 344, 433, 434, 443, 444, 3333, 3334, 3343, 3344, 343…
A number system with moduli is defined by a vector of k moduli, [m1,m2, ···,mk]. The moduli must be pairwise co-prime, which means that, for any pair of moduli, the only common factor is 1. In such a system each number n is represented by a string "-x…
Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight of the most significant bit (i.e., in position k-1), is -2^(k-1), and the weight of a bit in any position i (0 ≤ i < k-1) is 2^i. For example, a 3 bit…
The Stern-Brocot Number System Input: standard input Output: standard output The Stern-Brocot tree is a beautiful way for constructing the set of all nonnegative fractions m / n where m and n are relatively prime. The idea is to start with two fracti…
We define the smallest positive real number as the number which is explicitly greater than zero and yet less than all other positive real numbers except itself. The smallest positive real number, if exists, implies the existence of the second greater…
Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 1165   Accepted: 110 Case Time Limit: 5000MS Description May is a lovely girl. Due to her filial piety, she wants to give a present on her mother's birthday. Because both her parents are t…
http://poj.org/problem?id=2104 裸题不说.主席树水过. #include <cstdio> #include <iostream> #include <algorithm> using namespace std; #define dbg(x) cout << #x << "=" << x << endl #define read(x) x=getint() #define…
The Luckiest Number 题目大意:给你一个int范围内的正整数n,求这样的最小的x,使得:连续的x个8可以被n整除. 注释:如果无解输出0.poj多组数据,第i组数据前面加上Case i: 即可. 想法:这题还是挺好的.我最开始的想法是一定有超级多的数输出0.然后...我就在哪里找啊找....其实这道题是一道比较好玩儿的数论题.我们思考:连续的8可用什么来表示出来?$\frac{(10^x-1)}{9}\cdot 8$.其实想到这一步这题就做完了.这题的精髓就在于告诉我们连续的连…