日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

hdoj4648(Magic Pen 6)(前缀和)

發布時間:2023/12/20 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hdoj4648(Magic Pen 6)(前缀和) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=4648

Magic Pen 6

Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 2565????Accepted Submission(s): 913


Problem Description In HIT, many people have a magic pen. Lilu0355 has a magic pen, darkgt has a magic pen, discover has a magic pen. Recently, Timer also got a magic pen from seniors.

At the end of this term, teacher gives Timer a job to deliver the list of N students who fail the course to dean's office. Most of these students are Timer's friends, and Timer doesn't want to see them fail the course. So, Timer decides to use his magic pen to scratch out consecutive names as much as possible. However, teacher has already calculated the sum of all students' scores module M. Then in order not to let the teacher find anything strange, Timer should keep the sum of the rest of students' scores module M the same.

Plans can never keep pace with changes, Timer is too busy to do this job. Therefore, he turns to you. He needs you to program to "save" these students as much as possible.
Input There are multiple test cases.
The first line of each case contains two integer N and M, (0< N <= 100000, 0 < M < 10000),then followed by a line consists of N integers a1,a2,...an (-100000000 <= a1,a2,...an <= 100000000) denoting the score of each student.(Strange score? Yes, in great HIT, everything is possible)

Output For each test case, output the largest number of students you can scratch out.
Sample Input2 3 1 6 3 3 2 3 6 2 5 1 3
Sample Output1 2 0 Hint The magic pen can be used only once to scratch out consecutive students.

思路:大致是https://www.2cto.com/kf/201308/234446.html這位博主的思路,先把前綴和求出來,再枚舉0~M-1的模數,a[i~j]=sum[j]-sum[i], 求出最大區間長度. 見代碼: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int sum[100010]; int Hash1[10010]; int Hash2[10010]; int main() {int n,m,t;while(scanf("%d%d",&n,&m)!=EOF){memset(sum,0,sizeof(sum));memset(Hash1,-1,sizeof(Hash1));memset(Hash2,-1,sizeof(Hash2));for(int i=1;i<=n;i++){scanf("%d",&t);sum[i]=(sum[i-1]+t)%m;if(sum[i]<0)sum[i]=(sum[i]+m)%m;Hash1[0]=0;if(Hash1[sum[i]]==-1){Hash1[sum[i]]=i; }else{Hash2[sum[i]]=i; }}int len=0;for(int i=0;i<=m-1;i++){if(Hash2[i]==-1)continue;else{len=max(Hash2[i]-Hash1[i],len);}}printf("%d\n",len);}return 0; }

總結

以上是生活随笔為你收集整理的hdoj4648(Magic Pen 6)(前缀和)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 91香蕉视频在线 | 国产白浆视频 | 狠狠影院 | 性一交一乱一伧国产女士spa | 人妻妺妺窝人体色www聚色窝 | 久草成人 | 天天综合色 | 贝利弗山的秘密在线观看 | 女婴高潮h啪啪 | 在线看亚洲 | 国产小视频在线看 | 福利视频免费观看 | 日出白浆视频 | 国产精品久草 | 人人干人人搞 | 久久黄色精品视频 | 国产一区二区三区免费播放 | 久久影院精品 | 久久精品视频在线播放 | 色福利在线 | 超碰女人| 中文字幕日韩精品亚洲一区小树林 | 色香影院 | 国产午夜福利在线播放 | 在线中文字幕av | 免费福利在线观看 | 国产激情影院 | 操碰在线观看 | 美女一区二区三区四区 | 夜夜夜网站 | 国产一区二区黄色 | 成人免费毛片果冻 | 亚洲欧美在线观看视频 | 丰满肉嫩西川结衣av | 色啊色 | 91国在线 | 久久久噜噜噜www成人网 | 国产偷人妻精品一区二区在线 | 日本人xxxⅹ18hd19hd | 少妇一区二区视频 | 天天av天天操 | 激情xxx| 久久夜靖品2区 | 三级不卡视频 | 国产aⅴ精品一区二区三区久久 | 免费天堂av| 爱视频福利网 | 久久人成 | 99免费国产 | 日本天堂影院 | 精品欧美在线 | 日韩精品黄 | 插少妇视频 | 在线观看a网站 | 天天看天天干 | 四虎久久久久 | av大西瓜 | 成人高清视频免费观看 | 日韩激情一区二区 | www.亚洲综合 | 男操女免费网站 | 国产精品欧美日韩 | 日本中文字幕在线观看视频 | 久久久久国产一区二区三区潘金莲 | 久久99久久精品 | 强迫凌虐淫辱の牝奴在线观看 | 高清性爱视频 | 乱人伦中文字幕 | 国产高清www | 婷婷国产 | 日韩中文电影 | wwwwxxxx欧美 | 欧美三级a | 男人把女人捅爽 | 日韩专区欧美专区 | 好吊色视频一区二区 | 国产无遮挡又黄又爽免费网站 | 青草热视频 | 国产视频一区在线观看 | 99在线视频播放 | 久久av不卡 | 高清在线一区二区三区 | 精品国产黄色片 | 欧美日韩亚洲天堂 | 图片区 小说区 区 亚洲五月 | 91情侣视频 | 日本精品一区二区三区在线观看 | 小视频在线免费观看 | 日本免费一二区 | 天天夜夜啦啦啦 | 网站毛片 | 丰满白嫩尤物一区二区 | 久久精品国产一区二区 | 日韩在线精品 | 在线免费观看不卡av | 嫩草影院在线观看视频 | 欧美熟妇激情一区二区三区 | 丁香在线视频 | 国产在线网 |