Gym - 101128H:Sheldon Numbers】的更多相关文章

题意 给你两个整数X和Y 问你在区间[X,Y]中,有多少数字的二进制满足ABAB或者A这种形式.A是某个数量的1,B是某个数量的0. 分析 因为数据规模很大,直接枚举x和y之间的数字然后判断会超时.所以直接构造符合的二进制串然后判断是不是在区间[X,Y]内就好.因为二进制串的长度最多只有63,所以随便枚举就行.但是写起来确实麻烦,容易出错的地方太多. 下面的代码是在场上两个队友写的,场上的代码嘛~可能有点乱~(好吧是我懒得再写一遍了 #include <cstdio> #include <…
Sheldon Numbers GYM 题意:定义Sheldon Number为其二进制数是ABA……ABA型的或者ABAB……AB的,其中A全为1,B全为0(A>0, B>0),问[m, n]中有多少个Sheldon Number. 思路:只需要存储好所有A与B的情况,并枚举所有的ABA……ABA型的或者ABAB……AB的情况. # include <bits/stdc++.h> using namespace std; # define vi vector < int &…
Sheldon Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/H Description According to Sheldon Cooper, the best number is 73. In his own words, "The best number is 73. 73 is the 21st prime number. Its mirror, 37, is the 12th, and its m…
UVA - 13022 Sheldon Numbers 二进制形式满足ABA,ABAB数的个数(A为一定长度的1,B为一定长度的0). 其实就是寻找在二进制中满足所有的1串具有相同的长度,所有的0串也具有相同的长度,并且在给定范围内的个数. 位运算.通过分析不难发现,所有解不会很大,因此我们可以暴力,用两个for分别枚举0串和1串的长度,然后交替放入一个值内(注意先放1),同时更新答案. 将值存入set,发现所有满足条件的个数为4809(4810). ps:因为这里的2^63大于long lon…
POJ 3252:Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 3669 Description The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, Paper, Stone' (also known as 'Rock, Paper, Sciss…
[题目链接] http://codeforces.com/gym/101128/attachments [题目大意] 给出一张地图,分为高地和低地,高低地的交界线上划有红线, 现在要开小车跨过每条红线,当改变小车开的地形的时候,比如从高地开往低地, 就需要多耗油A单位,也可以花B的耗油量抬高地形或者降低地形, 问跨越所有红线所用的最少耗油量 [题解] 我们发现对于每条红线,我们需要花A去跨越地形或者花B去抬高或者降低地形, 所以我们将不同地形划分为两个集合,构成二分图, 红线左右块连流量为A的边…
http://codeforces.com/gym/101142/attachments 题意:每个人在TC和CF上分别有两个排名,如果有一个人在任意一个网站上大于另一个人的排名,那么这个人可以打败另外一个人.还有就是如果 B 能打败 A, C 能打败 B,但是 C 直接从排名上看 C 并不能打败 A,但是因为 B -> A 并且 C -> B,所以 C -> B -> A, 即 C 也能(通过打败 B 来)打败 A. 如这个样例: A :5, 5 , B :1, 6,  C:2,…
Product-sum numbers A natural number, N, that can be written as the sum and product of a given set of at least two natural numbers, {a1, a2, … , ak} is called a product-sum number: N = a1 + a2 + … + ak = a1 × a2 × … × ak. For example, 6 = 1 + 2 + 3 =…
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, …shows the first 11 ugly numbers. By convention, 1 is included.Write a program to find and print the 150′th ugly number. METHOD 1 (Simple…
                               Smith Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14521   Accepted: 4906 Description While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University,noticed tha…