码迷,mamicode.com
首页 > 其他好文 > 详细

bzoj3613 [Heoi2014]南园满地堆轻絮

时间:2017-05-28 23:17:28      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:using   include   efi   clu   unsigned   ide   logs   typedef   main   

传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3613

【题解】

其实挺显然。。就是最大逆序对差/2

技术分享
# include <stdio.h>
# include <string.h>
# include <iostream>
# include <algorithm>
// # include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int M = 5e6 + 10;

# define RG register
# define ST static

int n, SA, SB, SC, SD;
int a[M], mod; 

inline int F(int x) {
    ll ret = 1ll * SA * x % mod * x % mod * x % mod + 1ll * SB * x % mod * x % mod + 1ll * SC * x % mod + SD;
    return int(ret % mod);
}

int main() {
    cin >> n >> SA >> SB >> SC >> SD >> a[1] >> mod;
    for (int i=2; i<=n; ++i) { 
        a[i] = F(a[i-1]) + F(a[i-2]); 
        if(a[i] >= mod) a[i] -= mod;
    }
    int mx = -1, ans = 0;
    for (int i=1; i<=n; ++i) {
        if(mx >= a[i]) ans = max(ans, (mx-a[i]+1)>>1);
        mx = max(mx, a[i]);
    }
    cout << ans << endl;
    return 0;
}
View Code

 

bzoj3613 [Heoi2014]南园满地堆轻絮

标签:using   include   efi   clu   unsigned   ide   logs   typedef   main   

原文地址:http://www.cnblogs.com/galaxies/p/bzoj3613.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!