日韩性视频-久久久蜜桃-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)(前缀和)的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 老女人人体欣赏a√s | 成人免费视频国产在线观看 | 波多野结衣一区二区 | 国产99在线观看 | 欧美丰满美乳xxⅹ高潮www | 久久婷婷综合色丁香五月 | 亚洲视频中文字幕 | 天天av天天干 | 亚洲精品www | 中文字幕 欧美激情 | 欧美 日韩 国产 高清 | 黄色一级片a | 亚洲综合日韩 | 亚洲自拍天堂 | 日本一区二区精品视频 | 欧美日韩精品三区 | 亚洲精品在线免费播放 | 人妻精品久久久久中文字幕 | 亚洲视频观看 | 性生交大片免费看3p | 日韩成人短视频 | а√在线中文网新版地址在线 | 在线aa| 欧美一级专区免费大片 | 奴性白洁会所调教 | 喷水少妇| 中文天堂在线资源 | 国产又色又爽又黄的 | 国产91在线 | 亚洲 | 免费在线精品视频 | 精品亚洲精品 | 91免费高清在线观看 | 成人作爱视频 | 色射综合| 欧美91视频 | 欧日韩不卡视频 | 韩国日本在线 | 国产911视频 | 国产欧美日韩视频在线观看 | 午夜精品导航 | 精人妻一区二区三区 | 午夜天堂精品久久久久 | 黄色污污网站在线观看 | 精品一区在线播放 | 成年人免费在线观看网站 | 小箩莉末发育娇小性色xxxx | 久久精品8 | 免费人成在线观看 | 最新国产网站 | 免费操片| 都市激情校园春色 | 朝鲜美女黑毛bbw | 国产精品无码永久免费不卡 | 国产激情91| 成人av在线资源 | 开心激情站| 久久国产精品无码网站 | 中文字幕精品无 | 女人被狂躁60分钟视频 | 亚洲成人偷拍 | 国产性猛交xx乱 | 狂野欧美性猛交xxxx | 激情五月色播五月 | 激情开心成人网 | 四虎在线看片 | 91精品国产入口 | 狠狠躁日日躁夜夜躁2022麻豆 | 原来神马电影免费高清完整版动漫 | 国产又粗又猛又黄又爽的视频 | 国产精品国产三级国产aⅴ 欧美bbbbbbbbbbbb18av | 亚洲精品国产一区二区 | 农村搞破鞋视频大全 | 婷婷深爱网 | 欧美日韩中文字幕一区 | 免费日批网站 | 国产特级视频 | 高清国产一区二区 | 欧美亚洲精品一区二区 | 日韩亚洲视频 | 欧美日本国产 | 日本人の夫妇交换 | 国产精品高清在线观看 | 中文字幕在线观看一区二区 | 久草影视在线观看 | 久久永久免费 | 色综合狠狠 | 第一页在线视频 | 免费看黄色aaaaaa 片 | 小宵虎南在线观看 | 国产永久视频 | 午夜性视频 | 日韩欧美视频免费在线观看 | 国产亚洲精品精品精品 | 国产精品久久久久久亚洲av | av第一页 | 大黄一级片 | 欧美日韩国产精品一区 | 四虎4hu永久免费网站影院 | 午夜av毛片 |