hdu4648Magic Pen 6
http://acm.hdu.edu.cn/showproblem.php?pid=4648
求连续的一段和对m取余为0 若s[j]和s[i]对M的余数都相同 则相见就满足要求 找个最长的
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
using namespace std;
#define LL long long
#define N 100010
#define INF 0xfffffff
LL s[N];
int a[N],d1[N],d2[N];
int main()
{
int i,j,n,m,k;
while(cin>>n>>m)
{
memset(s,,sizeof(s));
LL sum=;
for(i = ; i <= m ; i++)
{
d1[i] = -INF;
d2[i] = INF;
}
int ans=;
for(i = ; i <= n ; i++)
{
scanf("%d",&a[i]);
sum+=a[i];
s[i] = s[i-]+a[i];
k = s[i]%m;
if(k<) k+=m;
if(k==)
ans = max(ans,i);
d1[k] = max(d1[k],i);
d2[k] = min(d2[k],i);
}
for(i = ; i < m ; i++)
ans = max(d1[i]-d2[i],ans);
cout<<ans<<endl;
}
return ;
}
hdu4648Magic Pen 6的更多相关文章
- WinForm------PanelControl控件中使用Pen类画角圆矩形方法
private void rightPanel_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Pen p = ,, ...
- GDI+图形图像处理技术中Pen和Brush的简单使用和简单图形的绘制(C#)
1.Graphics Graphics对象是GDI+绘图表面,因此在Windows窗体应用程序中要使用GDI+创建绘图,必须要先创建Graphics.在给窗体注册一个Paint事件后,Graphics ...
- [CareerCup] 12.5 Test a Pen 测试一支笔
12.5 How would you testa pen? 这道题让我们测试一支笔,我们需要问面试官许多问题来理解"who,what,where,when,how and why" ...
- hdu4486 Pen Counts(水题)
Pen Counts Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- Pen Editor
Pen Editor
- http://codepen.io/zhou-yg/pen/NqgPmg 在线编辑器
http://codepen.io/zhou-yg/pen/NqgPmg 在线编辑器
- 14 Live CDs for Penetration Testing (Pen Test) and Forensic
http://www.ivizsecurity.com/blog/penetration-testing/live-cd-penetration-testing-pen/ Yesterday I wa ...
- Magic Pen 6
Problem Description In HIT, many people have a magic pen. Lilu0355 has a magic pen, darkgt has a mag ...
- hdu 4486 Pen Counts
Pen Counts Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
随机推荐
- [MAXscript Tool]TimeSlider v1.3
一个简单的小工具,方便在MAX里面快速的修改帧速率,像maya一样.具体看视频演示.
- spring mvc 多视图配置
<!-- jsp视图解析器--> <bean id="viewResolver" class="org.springframework.web.serv ...
- QT Slot/Signal
QT的Slot/Singal-槽/信号 1.Usage/使用方法 所有从 QObject 或其子类 ( 例如 Qwidget) 派生的类都能够包含 信号/signal和 槽/slot.当对象改变其状态 ...
- [RMQ] [线段树] POJ 3368 Frequent Values
一句话,多次查询区间的众数的次数 注意多组数据!!!! RMQ方法: 预处理 i 及其之前相同的数的个数 再倒着预处理出 i 到不是与 a[i] 相等的位置之前的一个位置, 查询时分成相同的一段和不同 ...
- (LightOJ 1149) Factors and Multiples
题目链接:http://lightoj.com/volume_showproblem.php?problem=1149 Description You will be given two sets o ...
- OpenJudge 2757 最长上升子序列 / Poj 2533 Longest Ordered Subsequence
1.链接地址: http://poj.org/problem?id=2533 http://bailian.openjudge.cn/practice/2757 2.题目: 总Time Limit: ...
- HPDL380G8平台11.2.0.3 RAC实施手册
HPDL380G8平台11.2.0.3 RAC实施手册 1 前言 此文档详细描述了Oracle 11gR2 数据库在HPDL380G上的安装RAC的检查及安装步骤.文档中#表示root用户执行,$ ...
- vsftpd.conf配置详解
根据 /etc/vsftpd/vsftpd.conf默认配置给出设定功能 # Example config file /etc/vsftpd/vsftpd.conf # The default c ...
- jquery <li>标签 隔若干行 加空白或者加虚线
$(function () { $('ul li').addClass(function (i) { return i % 6 == 5 ? "ab" : "" ...
- Windows Server R2服务器 IIS7 部署MVC3网站
报错:调用 GetProcAddress 失败,在 ISAPI 筛选器 "C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi ...