zoukankan      html  css  js  c++  java
  • CF

    PS:换了一种方式 希望大家喜欢 2333

    /**
    code by: zstu wxk
    time: 2019/03/01
    Problem Link: http://codeforces.com/contest/1130/problem/E
    solve:
        如果构造的数列是 0 0 0 0 0 0 0 -1 + + + +(+代表大于0的数)
            那么 find_answer = sum(+) * len_+
            实际上的答案为 tot_len * [sum(+) - 1]
            即: sum(+) * len_+ + k = tot_len * [sum(+) - 1]
            接下来就是枚举tot_len就好了
    **/
    #include<bits/stdc++.h>
    using namespace std;
    #define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt","w",stdout);
    #define LL long long
    #define ULL unsigned LL
    #define fi first
    #define se second
    #define pb push_back
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define lch(x) tr[x].son[0]
    #define rch(x) tr[x].son[1]
    #define max3(a,b,c) max(a,max(b,c))
    #define min3(a,b,c) min(a,min(b,c))
    typedef pair<int,int> pll;
    const int inf = 0x3f3f3f3f;
    const int _inf = 0xc0c0c0c0;
    const LL INF = 0x3f3f3f3f3f3f3f3f;
    const LL _INF = 0xc0c0c0c0c0c0c0c0;
    const LL mod =  (int)1e9+7;
    const int N = 1e5 + 100;
    int n, k, t1, t2;
    int a[N];
    bool check(int x){
        for(int i = 2; i * i <= x; ++i){
            if(x % i == 0){
                t1 = i, t2 = x/i;
                t1 = n - t1;
                if(t1 < n - 2 && t2 < 1e6 * t1)
                    return true;
            }
        }
        return false;
    }
    void Ac(){
        n = 2000;
        memset(a, 0, sizeof a);
        for(n = 2000; n >= 1; --n){
            if(check(n+k)){
                for(int i = 1; i <= t1; ++i){
                    if(t2 >= 1e6){
                        a[i] = 1e6;
                        t2 -= 1e6;
                    }
                    else{
                        a[i] = t2;
                        t2 = 0;
                    }
                }
                a[t1+1] = -1;
                printf("%d
    ", n);
                reverse(a+1, a+1+n);
                for(int i = 1; i <= n; ++i){
                    printf("%d ", a[i]);
                }
                break;
            }
        }
    }
    int main(){
        while(~scanf("%d", &k)){
            Ac();
        }
        return 0;
    }
    View Code
  • 相关阅读:
    一个生成随机颜色的js函数
    实战vue代码
    vue练习用免费开源api大全
    vue-resource插件使用
    专题 查找与排序的Java代码实现(一)
    十字链表的画法
    20162322 朱娅霖 作业009 堆和优先队列
    20162322 朱娅霖 作业008 二叉查找树
    20162322 朱娅霖 实验报告二 树
    20162322 朱娅霖 作业007 树
  • 原文地址:https://www.cnblogs.com/MingSD/p/10456197.html
Copyright © 2011-2022 走看看