30分求救!!!
查看原帖
30分求救!!!
957640
Michelle01楼主2023/7/23 19:21
#include <stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    int f[n];
    int a[n];
    f[0] = 0;f[1] = 1;f[2] = 2;f[3] = 3;f[4] = 4; f[5] = 5;f[6] = 6;f[7] = 7;f[8] = 8;f[9] = 9;f[9] = 5;f[10] = 10;f[11] = 11;
    if(n > 11){
        for(int i = 1; i <= n; i++){
            a[i] = min(f[i - 1], f[i - 5]);
            f[i] = min(a[i], f[i - 11]) + 1;
        }
    }
    cout << f[n];

    return 0;
}
2023/7/23 19:21
加载中...