摘要:
#include#include#include#include#include#includeusing namespace std;int n;int ans[10];int a1[]={0,31,28,31,30,31,30,31,31,30,31,30,31};int a2[... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(80)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1201#sub注意的问题:送出去的钱是整数!#include#include#include#include#include#include#include using namespace std;int... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(105)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=3402 先看一下数据规模:n#include#include#include#include#include#includeusing namespace std;map ma; int n,m;in... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(258)
评论(0)
推荐(0)
摘要:
纪念一下,这是我自己第一个自己想出转移方程的dp题! 先定义一下数组,f[i][j]表示第i个人,抄了j本书花的最短时间。 w[i][j]表示[i,j]闭区间内,从第i本书抄到第j本书用的时间; 转移方程:f[h][i]=min(f[h][i],max(f[h-1][j],w... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(126)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1205大大大大大大枚举! 通过纸上画图来找各个情况中点与点的对应坐标关系。 还需要注意的问题:题目要求序号尽量靠前。#include#include#include#include#include#inc... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(96)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1052 观察数据,L到10^9,就是O(n)也不可以。 然后再观察数据,发现共才100个石子,对于桥的长度来说石子非常稀疏,中间有一大块空白区域。 状态转移方程: f[i]=min(f[i],f[i-... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(137)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1004#sub 四维做法基于可以看做俩个人,同时走。 从左上角到右下角步数是一定的,所以可以压缩到三维。#include#include#includeusing namespace std;int f... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(148)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1006#sub 和方格取数类似,可以看做同时从左上角出发,同时走,步数是同步的。 可以用四维数组,也可以用三维数组。 从左上角到右下角,步数是两点的曼哈顿距离。 得到状态转移方程 :int h=max(m... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(106)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1387法1:矩阵前缀和(n^3) 枚举点i,j 和边长o,如果右下角与左下角之间的数是完全平方数,既是正方形。#include#include#include#include#include#includ... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(139)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1313 系数应该是a^n*b^m*c(n,m),主要是求c(n,m) c(n,m)=n!/m!*(n-m)! 法1: 分解质因子#include#includeint su[20000],yz[2000... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(94)
评论(0)
推荐(0)
摘要:
评测 题目描述同上题。 其中n#include#include#define LL long long#define M 2147483647using namespace std;int n,a[300005],len;int up[300005];//up[i]记的是长度为i的的... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(89)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1020 法一,dp 第一问要求一个以第一个为起点最长不上升子序列。 第二问,只要后面的比前一个高,就要再另用一套系统,所以问题可以转化为求最长的上升子序列。#include#include... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(100)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1018#sub 其实这个数据范围貌似搜索是过不了的,但是在lg上过了 这里搜索的方法是,dfs(int x,LL ans,int bef),x表示已经用了几个乘号,ans表示前面放完乘号得到的乘积,be... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(66)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1091#sub问题转化为:枚举中间点,以此为终点求最长的上升子序列,以此为起点求最长下降子序列。#include#includeusing namespace std;int q[110],fq[110]... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(115)
评论(0)
推荐(0)
摘要:
问题转化为求1-n的欧拉函数的和*2+1#include#include#include#include#include#include#include#define LL long long#define M 1009using namespace std;int phi[M],p... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(82)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=3383#sub#include#include#include#include#include#include#include#define L long#define M 200000007using ... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(110)
评论(0)
推荐(0)
摘要:
http://poj.org/problem?id=3292如果一个数 i 是 H-素数,那么5i+4i*x一定是H数但不是H-素数, 因为(5i+4i*x)mod 4=5i mod 4=(5 mod 4)(i mod 4)=1*1=1,且5i+4i*x=i(4x+5).做法:先找出... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(60)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=3518问题描述: 有一个密码箱,0 到 n-1中的某些整数是它的密码,且满足:如果a和b都是它的密码,那么(a+b)%n 也是它的密码(a,b可以相等)某人试了k次密码,前k-1次都失败了,第k次成功了。... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(155)
评论(0)
推荐(0)
摘要:
由题目可得式子:m*t-n* t=y-x+q * l - - -> (n-m)*t+q*l=x-y令a=n-m,b=lc=x-y; a*t+b*l=c 求最小的正t令z=gcd(a,b) 先求a*t+b*q=z ① 当然如果c/z!=0就无解了 得出一组解t... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(342)
评论(0)
推荐(0)
摘要:
https://www.luogu.org/problem/show?pid=1290#sub 这题目好像辗转相除。 每次的两个数 a , b (a>b) 分为两种情况: 一, 此时状态为: a/b>1 ,那最完美的做法是取走(a/b-1)*b,那么剩下的两个数就为(a%b+b,b... 阅读全文
posted @ 2017-09-24 17:48
primes
阅读(99)
评论(0)
推荐(0)