题目链接:

Sum

Time Limit: 2000/1000 MS (Java/Others)  

  Memory Limit: 65536/65536 K (Java/Others)

Problem Description
 
There is a number sequence A1,A2....An,you can select a interval [l,r] or not,all the numbers Ai(l≤i≤r) will become f(Ai).f(x)=(1890x+143)mod10007.After that,the sum of n numbers should be as much as possible.What is the maximum sum?
 
Input
 
There are multiple test cases.
First line of each case contains a single integer n.(1≤n≤10^5)
Next line contains n integers A1,A2....An.(0≤Ai≤10^4)
It's guaranteed that ∑n≤10^6.
 
Output
 
For each test case,output the answer in a line.
 
Sample Input
2
10000 9999
5
1 9999 1 9999 1
 
Sample Output
19999
22033
 
 
题意:
 
给一个数组,选一个区间[l,r]把a[i]变成f(a[i]),也可以不选,问最后得到的这个数组的和最大是多少;
 
思路:
 
p[i]=(1890*a[i]+143)%10007;
然后就是在p[i]中找一个连续喝最大的字串,然后就好了;水题;
 
AC代码:
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio> using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<''||CH>'';F= CH=='-',CH=getchar());
for(num=;CH>=''&&CH<='';num=num*+CH-'',CH=getchar());
F && (num=-num);
}
int stk[], tp;
template<class T> inline void print(T p) {
if(!p) { puts(""); return; }
while(p) stk[++ tp] = p%, p/=;
while(tp) putchar(stk[tp--] + '');
putchar('\n');
} const LL mod=1e9+;
const double PI=acos(-1.0);
const LL inf=1e14;
const int N=1e4+;
const int maxn=; int p[*N],a[*N];
LL dp[*N];
int main()
{
int n;
while(cin>>n)
{
LL sum=,ans=;
Riep(n)read(a[i]),p[i]=(*a[i]+)%-a[i],sum=sum+a[i];
dp[]=;
for(int i=;i<=n;i++)
{
if(dp[i-]+p[i]<)dp[i]=;
else dp[i]=dp[i-]+p[i];
ans=max(ans,dp[i]);
}
cout<<sum+ans<<"\n";
} return ;
}
 
 

hdu-5586 Sum(dp)的更多相关文章

  1. hdu 5586 Sum【dp最大子段和】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5586 Sum Time Limit: 2000/1000 MS (Java/Others)    Me ...

  2. hdu 5586 Sum 基础dp

    Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Desc ...

  3. hdu 5586 Sum(dp+技巧)

    Problem Description There )mod10007.After that,the sum of n numbers should be as much as possible.Wh ...

  4. hdu 5586 Sum 最大子段和

    Sum Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5586 Desc ...

  5. hdu 5586 sum

    Problem Description There is a number sequence A1,A2....An,you can select a interval [l,r] or not,al ...

  6. HDU - 5586 Sum(区间增量最大)

    题意:将数组A的部分区间值按照函数f(Ai)=(1890*Ai+143)mod10007修改值,区间长度可以为0,问该操作后数组A的最大值. 分析:先求出每个元素的增量,进而求出增量和.通过b[r]- ...

  7. HDOJ(HDU).1003 Max Sum (DP)

    HDOJ(HDU).1003 Max Sum (DP) 点我挑战题目 算法学习-–动态规划初探 题意分析 给出一段数字序列,求出最大连续子段和.典型的动态规划问题. 用数组a表示存储的数字序列,sum ...

  8. HDU 2836 (离散化DP+区间优化)

    Reference:http://www.cnblogs.com/wuyiqi/archive/2012/03/28/2420916.html 题目链接: http://acm.hdu.edu.cn/ ...

  9. hdu 3507 斜率dp

    不好理解,先多做几个再看 此题是很基础的斜率DP的入门题. 题意很清楚,就是输出序列a[n],每连续输出的费用是连续输出的数字和的平方加上常数M 让我们求这个费用的最小值. 设dp[i]表示输出前i个 ...

  10. hdu 4507 数位dp(求和,求平方和)

    http://acm.hdu.edu.cn/showproblem.php?pid=4507 Problem Description 单身! 依旧单身! 吉哥依旧单身! DS级码农吉哥依旧单身! 所以 ...

随机推荐

  1. iisapp 命令 弹出 iisschlp.wsc [88,25] 属性值无效 progid

    iisapp 命令 弹出 iisschlp.wsc [88,25] 属性值无效 progid 在执行iisapp.vbs时,可能会提示如下错误:Windows Script Component - f ...

  2. 【绝密外泄】风哥Oracle数据库DBA高级工程师培训视频教程与内部资料v0.1

    [绝密外泄]风哥Oracle数据库DBA高级工程师培训视频教程与内部资料v0.1 由于是[绝密外泄]资料,防止被查,需要的小伙伴赶紧下载附件中的课件文档.由于视频太大了,已放在百度网盘了,已经在附中说 ...

  3. StringUtils 字符串工具类

    package com.thinkgem.jeesite.common.utils; import java.io.File; import java.io.IOException; import j ...

  4. HITAG 2 125kHz RFID IC Read-Write 256 bits

    Features 256 bits EEPROM memory organized in 8 pages of 32 bits each 32 bits unique factory programm ...

  5. Linux(Centos)配置OpenSSH无密码登陆<转>

    最近在搭建Hadoop环境需要设置无密码登陆,所谓无密码登陆其实是指通过证书认证的方式登陆,使用一种被称为"公私钥"认证的方式来进行ssh登录.   " 公私钥" ...

  6. Codeforces 427 D. Match &amp; Catch

    后缀数组.... 在两个串中唯一出现的最小公共子串 D. Match & Catch time limit per test 1 second memory limit per test 51 ...

  7. Codeforces Round #310 (Div. 2) B. Case of Fake Numbers 水题

    B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  8. 微软ASP.NET网站部署指南(4):配置项目属性

    1.  综述 有些部署设置能够在项目属性里设置的,而且保持到项目文件中(.csproj或.vbproj). 大多数情况下.你都能够在Visual Studio 选择项目属性Project Proper ...

  9. python中的reduce(转)

    python中的reduce内建函数是一个二元操作函数,他用来将一个数据集合(链表,元组等)中的所有数据进行下列操作:用传给reduce中的函数 func()(必须是一个二元操作函数)先对集合中的第1 ...

  10. 进程控制之exit函数

    进程有下面5种正常终止方式: (1)在main函数内执行return语句.这等效于调用exit. (2)调用exit函数.此函数有ISO C定义,其操作包括调用各终止处理程序(终止处理程序在调用ate ...