BestCoder Round #62 (div.2) 1004

好长时间没做比赛了,原来就菜现在更菜,1004的题目没想到div.2赛后只有一个人做出来,做题的时候想到了做法但时间不多自己的奇葩代码不足以在比赛时间debug出来,赛后补了一发:

题目&提交地址在这:http://acm.hdu.edu.cn/showproblem.php?pid=5565

const int INF = 1000000000;
const double eps = 1e-8;
const int maxn = 10000000 + 10;
const int mod = 1000000000 + 7;
int n,q;
long long seed;
int rand(int l, int r) {
    static long long mo=1e9+7, g=78125;
    return l+((seed*=g)%=mo)%(r-l+1);
}
int num[maxn];
long long  snum[maxn];
long long sum[maxn];
int sumnum[maxn];
struct pp{
    int id;
    int v;
}a[maxn];
bool cmp(pp p1 ,pp p2){
    return p1.v < p2.v;
}
bool cmp1(pp p1,pp p2){
    return p1.id < p2.id;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int T;
    scanf("%d",&T);
    while(T--){
        clr(num);
        clr(snum);
        clr(sumnum);
        scanf("%d%d%I64d",&n,&q,&seed);
        int ssum=rand(q, 10000000);
        for(int i=1; i<=n; i++) {
            a[i].v=rand(0, ssum/(n-i+1));
            a[i].id = i;
            ssum-=a[i].v;
        }
        a[rand(1, n)].v+=ssum;
        //repf(i,1,n) cout<<a[i].v<<endl;
        //cout<<"...."<<endl;
        sort(a+1,a+n+1,cmp);
        int nn = 1;
        int cmpp = a[n].v;
        num[nn]++;
        snum[nn] = a[n].v;
        repd(i,n-1,1){
            if(a[i].v == cmpp) num[nn]++;
            else{
                nn++;
                num[nn]++;
                cmpp = a[i].v;
                snum[nn] = a[i].v;
            }
        }
        //cout<<"num "<<nn<<endl;
        sumnum[0] = 0;
        sum[0] = 0;
        repf(i,1,nn) sumnum[i] = sumnum[i-1] + num[i];
        repf(i,1,nn-1) sum[i] = sum[i-1] + (snum[i] - snum[i+1])*sumnum[i];
        sum[nn] = sum[nn-1] + sumnum[nn]*snum[nn];
      //  cout<<"total "<<sum[nn]<<endl;
       // cout<<"first "<<sum[1]<<endl;
        int id = 0;
        repf(i,1,nn){
            if(q <= sum[i]){
                id = i;
                break;
            }
        }
        repf(i,1,n) if(a[i].v > snum[id]) a[i].v = snum[id];
        int left = (q - sum[id - 1])%sumnum[id];
        int tt = (q - sum[id - 1])/sumnum[id];
        int cc = snum[id] - tt;
        repf(i,1,n) if(a[i].v == snum[id]) a[i].v-=tt;
        sort(a+1,a+1+n,cmp1);
        repf(i,1,n) if(a[i].v == cc){
            if(left) left--,a[i].v--;
            else{
                break;
            }
        }
        //repf(i,1,n) cout<<a[i].v<<endl;
        if(q  >= sum[nn]) repf(i,1,n) a[i].v = 0;
        int ans = a[1].v + a[1].id;
        repf(i,2,n)   ans ^= (a[i].v + a[i].id);
        printf("%d\n",ans);
    }
    return 0;
}
时间: 2025-01-02 17:42:42

BestCoder Round #62 (div.2) 1004的相关文章

HDU5526/BestCoder Round #61 (div.1)1004 Lie 背包DP

Lie 问题描述 一个年级总共有N个学生,每个人属于唯一一个班级.现在他们站在一排,同班同学并不一定会站在一起,但每个人都会说一句话:“站在我左边的有Ai个同班同学,右边有Bi个同班同学”.然而并不是每个人都会说真话,老师也忘了他们说话的顺序,现在老师想知道最多有多少人的话同时不矛盾. 输入描述 输入有多组数据,不超过100组. 每组数据第一行包含一个整数N.(1\leq N\leq 1000 )(1≤N≤1000) 随后N行,每行包含两个数字Ai和Bi.(0\leq Ai,Bi\leq 100

计算几何(水)BestCoder Round #50 (div.2) 1002 Run

题目传送门 1 /* 2 好吧,我不是地球人,这题只要判断正方形就行了,正三角形和正五边形和正六边形都不可能(点是整数). 3 但是,如果不是整数,那么该怎么做呢?是否就此开启计算几何专题了呢 4 */ 5 /************************************************ 6 * Author :Running_Time 7 * Created Time :2015-8-8 19:54:14 8 * File Name :B.cpp 9 ************

hdu5418 BestCoder Round #52 (div.2) Victor and World ( floyd+状压dp)

Problem Description After trying hard for many years, Victor has finally received a pilot license. To have a celebration, he intends to buy himself an airplane and fly around the world. There are n countries on the earth, which are numbered from 1 to

BestCoder Round #11 (Div. 2) 前三题题解

题目链接: huangjing hdu5054 Alice and Bob 思路: 就是(x,y)在两个參考系中的表示演全然一样.那么仅仅可能在这个矩形的中点.. 题目: Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 216    Accepted Submission(s): 166 Problem De

BestCoder Round #11 (Div. 2) 题解

HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 302    Accepted Submission(s): 229 Problem Description Bob and Alice got separated in the Square, they agreed that if they

HDU 5651 xiaoxin juju needs help(BestCoder Round #77 (div.1)1001)

传送门 xiaoxin juju needs help Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 861    Accepted Submission(s): 243 Problem Description As we all known, xiaoxin is a brilliant coder. He knew **palin

BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)

Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 681    Accepted Submission(s): 280 Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(the

BestCoder Round #50 (div.2)

题目传送:BestCoder Round #50 (div.2) BC感觉越做越无语了 1001.Distribution money AC代码: #include <map> #include <set> #include <list> #include <cmath> #include <deque> #include <queue> #include <stack> #include <bitset> #

HDU 5671 Matrix (BestCoder Round #81 (div.2) 1002)

传送门 Matrix Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 311    Accepted Submission(s): 142 Problem Description There is a matrix M that has n rows and m columns (1≤n≤1000,1≤m≤1000).Then we