Educational Codeforces Round 33 (Rated for Div. 2) B题

B. Beautiful Divisors

Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes.

Some examples of beautiful numbers:

12 (110);
1102 (610);
11110002 (12010);
1111100002 (49610).
More formally, the number is beautiful iff there exists some positive integer k such that the number is equal to (2k - 1) * (2k - 1).

Luba has got an integer number n, and she wants to find its greatest beautiful divisor. Help her to find it!

Input
The only line of input contains one number n (1 ≤ n ≤ 105) — the number Luba has got.

Output
Output one number — the greatest beautiful divisor of Luba‘s number. It is obvious that the answer always exists.

Input

3

Output

1

思路:看了看数据范围。QAQ,发现可以打表===水过

AC代码:

 1 #include<bits/stdc++.h>
 2
 3 using namespace std;
 4 int arr[]={1,6,28,120 ,496 ,2016, 8128,32640, 130816 ,523776};
 5 int main(){
 6     int n;
 7     cin>>n;
 8     for(int i=9;i>=0;i--){
 9         if(arr[i]>n)
10             continue;
11         if(arr[i]==n){
12             printf("%d",n);return 0;
13         }
14         if(n%arr[i]==0){
15             cout<<arr[i];return 0;
16         }
17     }
18     return 0;
19 } 

原文地址:https://www.cnblogs.com/pengge666/p/11511073.html

时间: 2024-11-06 07:09:39

Educational Codeforces Round 33 (Rated for Div. 2) B题的相关文章

Educational Codeforces Round 33 (Rated for Div. 2) A题

A. Chess For Three Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game fo

Educational Codeforces Round 33 (Rated for Div. 2) C题&#183;(并查集变式)

C. Rumor Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it

Educational Codeforces Round 74 (Rated for Div. 2)补题

慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ? ? //√,×,? 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x>y)\),问能否将\(x-y\)拆成任意多个质数之和 1.任意大于\(1\)的整数\(k\)都可以用\(2\)与\(3\)的线性表示 证: 若\(k\)是偶数,显然: 若\(k\)是奇数,则\(k\)可以表示成\(k = 3 + 2*k'\),显然: 毕. #include<bits/stdc++.h&

Educational Codeforces Round 34 (Rated for Div. 2) B题【打怪模拟】

B. The Modcrab Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab. After two hours of playing the game Vova has tracked the monster and analyzed its tactics

codeforces Educational Codeforces Round 55 (Rated for Div. 2) C题 C. Multi-Subject Competition

这道题比赛时候没做出来,下来一看才发现是排序傻逼题. 把每个偏好的人做成一个vector,从大到小排序,做一个前缀和.然后将每种人数做一个桶,在桶里装每种科目选择人数为i的时候分数总和. 遍历每一维vector,把各个位置上面的vector加到sum数组中,最后sum数组里面挑出最大值. #include<bits/stdc++.h> using namespace std; typedef long long ll; vector<int> vec[100010];//vecto

Educational Codeforces Round 63 (Rated for Div. 2) B题

题目网址:https://codeforc.es/contest/1155/problem/B 题目大意:有两个人A,B博弈,在一串数字中,A先取数,B后取数,最后剩11个数的时候停止,如果第一个数是8,则A胜,反之B胜 题解:取数到最后,只剩11个数,且,A如果要赢,第一个数是8,则A显然是要尽可能的先取前面的非8数,B要先去前面的8,按照这样的策略,只需考虑前面n -10个数取到最后是否有8即可,显然是判断8的数量和其他数的数量的大小即可. 1 #include<bits/stdc++.h>

Educational Codeforces Round 63 (Rated for Div. 2) D题

题目网址:https://codeforc.es/contest/1155/problem/D 题目大意:给定n个数和一个k,可以对这n个数进行一次操作,也可以不进行,即选择某个区间中的数都乘上k,问最后最大连续子段和是多少? 题解:(鶸鶸的我是看别人的博客才解决的 ! ) 首先这道题的状态很多,对于前m个数,乘k之前的状态,乘k的状态,之和的状态都需要建立.那么分别设dp1,dp2,dp3是乘k之前,乘k时,乘k之和,前m个数最大连续子段和. 首先对于dp1,即一组数的最大子段和,显然只要是正

Educational Codeforces Round 78 (Rated for Div. 2) --补题

链接 直接用数组记录每个字母的个数即可 #include<bits/stdc++.h> using namespace std; int a[26] = {0}; int b[26] = {0}; int judge() { //cout<<"111"<<endl; for (int i = 0; i < 26; ++i) { if (a[i]!=b[i]) { return 0; } } return 1; } int main() { //

Educational Codeforces Round 57 (Rated for Div. 2)

get人生第二场CF! 成绩:(exACM) rank858 AC3/7 Penalty57 rating1648(+52) 题目:Educational Codeforces Round 57 (Rated for Div. 2) 错题题解: D. Easy Problem E. The Top Scorer F. Inversion Expectation G. Lucky Tickets 原文地址:https://www.cnblogs.com/xht37/p/10198321.html