摘要: 这个题是数位dp,dp[i][j][h]表示到第i为有h个0,j=1小于0等于,可以求出答案。 #include<stdio.h> int dp[41][2][41];//kge1 int a[41],lena; void init(){ dp[1][1][1]=dp[1][0][0]=1; for 阅读全文
posted @ 2020-08-30 22:06 __int128 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.luogu.com.cn/problem/P3195 对于这道题,可以用斜率优化的方法, 转移方程 dp[i]=min(dp[j]+(i-j-L-1+sun[i]-sum[j])^2),i>j; 可以转化为 (2(sun[i]+i)(sum[j]+j+L)+(dp[ 阅读全文
posted @ 2020-08-30 21:49 __int128 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 这个题可以用莫队的方法来解决,通过创建数组来保存数的出现个数,再在每次添加或删除的时候保存一个答案,这样就能做出这道题。 #include<stdio.h> #include<math.h> struct node{ int l,r,id; }a[100001],pxr[100001]; int n 阅读全文
posted @ 2020-08-30 21:47 __int128 阅读(140) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> #include<string.h> #define yw 10000 //yw表示压4位数 struct node{ int s[10001];//s存储数据 int len,zf;//len存储位数,zf存储正负(1为正-1为负) }; char dr[100 阅读全文
posted @ 2020-05-18 19:21 __int128 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 链接:https://www.luogu.com.cn/problem/P1290 题目描述 欧几里德的两个后代 Stan 和 Ollie 正在玩一种数字游戏,这个游戏是他们的祖先欧几里德发明的。给定两个正整数 M 和 N,从 Stan 开始,从其中较大的一个数,减去较小的数的正整数倍,当然,得到的 阅读全文
posted @ 2020-05-16 21:32 __int128 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 题目链接: 洛谷:https://www.luogu.com.cn/problem/P1661 信息奥赛一本通:http://ybt.ssoier.cn:8088/problem_show.php?pid=1437 1437:扩散 时间限制: 1000 ms 内存限制: 65536 KB提交数: 6 阅读全文
posted @ 2020-05-09 20:47 __int128 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.luogu.com.cn/problem/P2949 题目描述 Farmer John has so very many jobs to do! In order to run the farm efficiently, he must make money on 阅读全文
posted @ 2020-05-03 21:26 __int128 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1427 1427:数列极差 时间限制: 1000 ms 内存限制: 65536 KB提交数: 1681 通过数: 757 【题目描述】 在黑板上写了N个正整数作成的一个数列,进行如下操作:每一次 阅读全文
posted @ 2020-05-02 20:51 __int128 阅读(606) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.luogu.com.cn/problem/P4305 题目描述 给定 n 个数,要求把其中重复的去掉,只保留第一次出现的数。 输入格式 本题有多组数据。 第一行一个整数 T ,表示数据组数。 对于每组数据: 第一行一个整数 n 。 第二行 n 个数,表示给定的数。 阅读全文
posted @ 2020-04-25 21:56 __int128 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.luogu.com.cn/problem/P2697 题目描述 有一种宝石串,由绿宝石和红宝石串成,仅当绿宝石和红宝石数目相同的时候,宝石串才最为稳定,不易断裂。安安想知道从给定的宝石串中,可以截取一段最长的稳定的宝石串,有多少颗宝石组成。请你帮助他。 绿宝石用‘G 阅读全文
posted @ 2020-04-25 21:08 __int128 阅读(221) 评论(0) 推荐(0) 编辑