【Educational Codeforces Round 33 B】Beautiful Divisors

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

把所有的那些数字打表出来。 逆序枚举就好

【代码】

/*
  	1.Shoud it use long long ?
  	2.Have you ever test several sample(at least therr) yourself?
  	3.Can you promise that the solution is right? At least,the main ideal
  	4.use the puts("") or putchar() or printf and such things?
  	5.init the used array or any value?
  	6.use error MAX_VALUE?
  	7.use scanf instead of cin/cout?
*/
#include <bits/stdc++.h>
using namespace std;

int n,pre[20],len;
long long temp[20];
vector <int> v;

int main(){
	#ifdef LOCAL_DEFINE
	    freopen("F:\c++source\rush_in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0),cin.tie(0);


	pre[0] = 1;
	for (int i = 1;i < 20;i++){
		pre[i] = pre[i-1]*2;
	}	

	for (int i = 1; ;i++){
		temp[i] = 1LL*(pre[i]-1)*(pre[i-1]);
		if (temp[i]>(int) 1e5){
			len = i-1;
			break;
		}
   	}

	cin >> n;
	for (int i = 1;i <= n;i++){
		if (n%i==0){
		 	v.push_back(i);
	 	}
	}

	for (int i = (int) v.size()-1;i >= 0;i--){
	 	for (int j = 1;j <= len;j++)
	 		if (temp[j]==v[i]){
	 		 	cout << v[i] << endl;
	 		 	return 0;
	 		}
	}

	return 0;
}
原文地址:https://www.cnblogs.com/AWCXV/p/7888304.html