Sum

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 507    Accepted Submission(s): 284

Problem Description
There is a number sequence A1,A2....An

,A1,A2....An

,A1,A2....An

,A1,A2....An

,A1,A2....An

,A1,A2....An

,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≤105)
Next line contains n integers A1,A2....An
.(0≤Ai≤104)
It's guaranteed that ∑n≤106
.
 
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
 
Source
 
传送门 http://acm.hdu.edu.cn/showproblem.php?pid=5586
类似杭电1003
题意  一串序列 可以只能更改一个区间 或不更改f(x)=(1890x+143)mod10007    更改操作为f(x)=(1890x+143)mod10007
询问 这串序列的和的最大值
做一个变形 每个值变为 f(x)-x 然后按照1003的方法 求最大连续区间的和 
dp[i]=max(dp[i],dp[i-1]+dp[i]);
 
f(x)=(1890x+143)mod10007
 
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n;
int bac(int s)
{
return (1890*s+143)%10007;
}
int b[100005],a[100005];
int main()
{
while(scanf("%d",&n)!=EOF)
{
memset(b,0,sizeof(b));
memset(a,0,sizeof(a));
int re=0;
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
re=re+a[i];
b[i]=bac(a[i])-a[i];
}
// int exm=0;
int maxn=0;
for(int i=1;i<n;i++)
{
if(b[i]+b[i-1]>b[i])
b[i]=b[i]+b[i-1];
if(b[i]>maxn)
maxn=b[i]; }
printf("%d\n",re+maxn);
}
return 0;
}

最新文章

  1. Linux+PHP+MySql网站迁移配置
  2. iOS通讯录整合,兼容iOS789写法,附demo
  3. 解决Spark读取Hive分区表出现Input path does not exist的问题
  4. lsyncd 实时同步
  5. Arduino示例教程超声波测距实验
  6. NopCommerce 开源商城下载配置安装
  7. ZOJ2588 Burning Bridges(割边模板)
  8. 优化Laravel网站打开速度
  9. EF——Guid类型数据的自增长、时间戳和复杂类型的用法 03 (转)
  10. response对象详解
  11. [转载]ios app 发布遇到的问题uinewsstandapp=true
  12. HTML5新属性-----拖放
  13. hdu 1098 Ignatius&#39;s puzz
  14. js的几种简单排序算法及其效率实测
  15. python的列表(二)
  16. 微信小程序 画布drawImage实现图片截取
  17. linux 下tftpf搭建
  18. 批处理no.bat
  19. Vue 中 export及export default的区别
  20. jgGrid

热门文章

  1. 关于@media不生效的问题和meta总结
  2. Click Once使用总结
  3. array.some() 方法兼容ie8
  4. [C++] OOP - Access Control and Class Scope
  5. Linux中常用的关机和重新启动命令
  6. TCP系列22—重传—12、Forward Retransmit
  7. requests保持cookies的问题
  8. phpcms 最多上传 10 个附件 解决办法
  9. 我们在删除SQL Sever某个数据库表中数据的时候,希望ID重新从1开始,而不是紧跟着最后一个ID开始需要的命令
  10. Java接口成员变量