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 ...
随机推荐
- Objective-C 【继承、变量修饰符(私有变量/方法)、description方法】
------------------------------------------- 继承 一段代码: #import <Foundation/Foundation.h> @interf ...
- 12天学好C语言——记录我的C语言学习之路(Day 9)
12天学好C语言--记录我的C语言学习之路 Day 9: 函数部分告一段落,但是我们并不是把函数完全放下,因为函数无处不在,我们今后的程序仍然会大量运用到函数 //转入指针部分的学习,了解指针是什么 ...
- 关于XML与类型Class的映射
我们知道数据的持久化是编程必须面对的问题.我们可以保存数据到数据库.Excel表.XML文件.TXT文件等等.那么我们编程中经常会遇到对Xml文件的操作.在http://www.cnblogs.com ...
- hdu 1715 大菲波数(高精度数)
Problem Description Fibonacci数列,定义如下: f(1)=f(2)=1 f(n)=f(n-1)+f(n-2) n>=3. 计算第n项Fibonacci数值. Inpu ...
- Headfirst设计模式的C++实现——组合模式(Composite)
menu_component.h #ifndef _MENU_COMPONENT_H_ #define _MENU_COMPONENT_H_ #include <string> class ...
- C++ GUI Qt4编写的文本编辑器
mainwindow.h: #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMenu> #include <QAction& ...
- HBase的安装与使用
1.安装 由于还是学习阶段,所以没有在生产环境练习,就在本地建了个虚拟机进行HBase的安装. 下载地址http://www.apache.org/dyn/closer.cgi/hbase/,选择一个 ...
- easy-ui datagrid
Easy-ui引用 <link href="css/EasyUI/themes/icon.css" rel="stylesheet" type=&q ...
- 实现strlen,strcpy,strcat,strcmp同功能的函数stringLength,stringCopy,stringCatch,stringCompare
#import <Foundation/Foundation.h> /* 求字符串长度 */ int stringLength(char arr[]); /* 复制字符串 将arr1 复制 ...
- The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'.
Exception when executing ) br is a binary reader. The data to peak is D000 (D0=208) The cause is, fo ...