CF893B.Beautiful Divisors

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 (2_k_ - 1) * (2_k_ - 1).

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

最近,Luba 学习了一类特殊的数,她称之为“优美数”(beautiful numbers)。一个数被称为优美数,当且仅当它的二进制表示由 k + 1 个连续的 1 后接 k 个连续的 0 构成。

一些优美数的例子:

  • 1210=1100212_{10} = 1100_2;
  • 1102=610110_2 = 6_{10};
  • 11110002=120101111000_2 = 120_{10};
  • 1111100002=49610111110000_2 = 496_{10}。

更严格地,一个数是优美数,当且仅当存在某个正整数 kk,使得该数等于 (2k+1−1)⋅2k(2^{k+1} - 1) \cdot 2^k。

Luba 得到了一个整数 nn,她希望找出 nn 的最大的优美因子(即能整除 nn 的最大优美数)。请帮她找到它!

输入格式

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

输入仅包含一行,其中有一个数字 nn(1 ≤ n ≤ 1051 \le n \le 10^5)——即 Luba 得到的数字。

输出格式

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

输出一个数字——卢巴数字的最大优美因数。显然,答案一定存在。

输入输出样例

  • 输入#1

    3

    输出#1

    1
  • 输入#2

    992

    输出#2

    496

输入解题思路,AI测评打分。不知道怎么写?

首页