382 Div 2 cf 1

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.明天补=_=

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值