我是靠谱客的博主 会撒娇大叔,这篇文章主要介绍剪不重复的气球串(360编程题),现在分享给大家,希望可以做个参考。

#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <math.h>
using namespace std;

#define MY_MAX 1000000007

long long funcN(int n, int maxNum){
    long long rtn = 1;
    for(int i = 0; i <= n-29; i += 29){
        rtn *= pow(2,29);
        rtn %= maxNum;
    }
    rtn *= pow(2,n%29);
    rtn %= maxNum;
    return rtn;
}

int cutBa(int a[], int n){
    int count = 0;
    set<int> s = set<int>();
    for (int i = 0; i < n; i++)
    {
        if(s.count(a[i]) != 0){
            count++;
            s.clear();
        }
        s.insert(a[i]);

    }
    return (int)funcN(n-1-count,MY_MAX);
}

转载于:https://my.oschina.net/u/272350/blog/862044

最后

以上就是会撒娇大叔最近收集整理的关于剪不重复的气球串(360编程题)的全部内容,更多相关剪不重复内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(42)

评论列表共有 0 条评论

立即
投稿
返回
顶部