B.贪心下,去掉最小的n - n1 - n2个,对剩下的求
sum1/n1 + sum2/n2,(n1 > n2 &&sum1 < sum2)答案最大
C.研究下就是斐波那契
#include <set>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
using namespace std;
typedef long long LL;
const int maxn = 100005;
LL n;
void init() {
cin>>n;
LL f[1005];
memset(f,0,sizeof f);
f[1] = 2;
f[2] = 3;
for(int i=3;1;i++){
f[i] = f[i-1] + f[i-2];
if(f[i] >= (LL)1e18) break;
}
for(int i=1;1;i++){
if(n<f[i]&&n>=f[i-1]){
cout<<i-1<<endl;
break;
}
}
}
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif // LOCAL
init();
return 0;
}
D.
给一个n,n最少由几个质数求和所得
4 = 2 + 2,2个
哥德巴赫猜想是
偶数可以拆成两个质数
所以
如果n 不是质数且n是奇数
那有两种情况
第一种情况答案是2
第二种情况答案为3
1. n = x + 2,只有这种符合第一种
2. n = 3 + (n - 3)
#include <set>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
using namespace std;
typedef long long LL;
const int maxn = 100005;
int n;
bool ok(int k) {
int tot = (int)(sqrt(k) + 0.5);
for(int i = 2; i <= tot; i++) {
if(k % i == 0) {
return false;
}
}
return true;
}
void init() {
cin >> n;
if(n%2){
if(ok(n)) cout<<1<<endl;
//在此之后n要是由两个质数组成,n是奇数,所以只能有2 + x,其他情况全是3
else if(ok(n-2)) cout<<2<<endl;
else cout<<3<<endl;
}
else cout<<(n==2?1:2)<<endl;
}
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif // LOCAL
init();
return 0;
}
E.明天补=_=