Educational Codeforces Round 33 (Rated for Div. 2) B - Beautiful Divisors
2017-11-24 22:16
751 查看
枚举K
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100 + 7, maxd = 670000 + 7;
const ll mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;
int main() {
ios::sync_with_stdio(0);
int n;
cin >> n;
int ans = 1;
int a = 4, b = 2;
for(int k = 2; ; ++k) {
int t = (a-1) * (b);
if(t > n) break;
if(n % (t) == 0) ans = t;
a *= 2; b *= 2;
}
cout << ans << endl;
return 0;
}
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100 + 7, maxd = 670000 + 7;
const ll mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;
int main() {
ios::sync_with_stdio(0);
int n;
cin >> n;
int ans = 1;
int a = 4, b = 2;
for(int k = 2; ; ++k) {
int t = (a-1) * (b);
if(t > n) break;
if(n % (t) == 0) ans = t;
a *= 2; b *= 2;
}
cout << ans << endl;
return 0;
}
相关文章推荐
- Educational Codeforces Round 33 (Rated for Div. 2)A-F
- Educational Codeforces Round 33 (Rated for Div. 2)
- Educational Codeforces Round 33 (Rated for Div. 2)A-F
- Educational Codeforces Round 33 (Rated for Div. 2) A-C题解
- Educational Codeforces Round 33 (Rated for Div. 2) A题. Chess For Three
- Educational Codeforces Round 33 (Rated for Div. 2) A - Chess For Three
- Educational Codeforces Round 33 (Rated for Div. 2) F - Subtree Minimum Query
- Educational Codeforces Round 33 (Rated for Div. 2) B题. Beautiful Divisors
- Educational Codeforces Round 33 (Rated for Div. 2) C - Rumor
- Educational Codeforces Round 33 (Rated for Div. 2) D. Credit Card
- Educational Codeforces Round 33 (Rated for Div. 2) D题. Credit Card(贪心)
- Educational Codeforces Round 33 (Rated for Div. 2) C
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)B
- Educational Codeforces Round 33 (Rated for Div. 2) 题解
- Educational Codeforces Round 33 (Rated for Div. 2)
- Educational Codeforces Round 33 (Rated for Div. 2) F. Subtree Minimum Query (线段树)
- Educational Codeforces Round 33 (Rated for Div. 2)
- Educational Codeforces Round 33 (Rated for Div. 2)【C】【并查集】
- Educational Codeforces Round 40 (Rated for Div. 2) B. String Typing
- Educational Codeforces Round 35 (Rated for Div. 2) D. Inversion Counting