自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

随风而行的博客

岁月无声

  • 博客(26)
  • 收藏
  • 关注

原创 51nod-1033 骨牌覆盖 V2

地址:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1033思路:状态压缩DP+矩阵快速幂对于每行最多只有5列,因此可以枚举出它们的全部状态 0->(1<<m)-1,对于状态其二进制1表示已经有骨牌覆盖,0表示没有,1.由于是1X2的骨牌,则二进制数11,110是合法的,1,10是不合法...

2018-09-28 15:22:33 359

原创 POJ-1185 炮兵阵地

地址:http://poj.org/problem?id=1185思路:状态压缩DP,对每行的状态进行枚举,由于一个炮兵影响相邻两行,因此用 dp[i][j][k]来保存 第i行的状态为j,第 i-1行状态为k时的最大个数。Code :#include<iostream>#include<cstring>using namespace std;co...

2018-09-27 19:44:35 377

原创 POJ-3311 Hie with the Pie

地址:http://poj.org/problem?id=3311思路:状态压缩dp,dp[i][j]:表示在状态i以点j为结尾时的最小距离。状态i表示已经走过了点,对于n个点,一共有0 -> (1<<n)-1个状态,因此dp[i][j]=min{dp[i-去除的点j][k]+G[k][j]}dp[i+新加入的点j][j]=min{dp[i][k]+G[k][j]...

2018-09-27 14:55:38 158

原创 POJ-3254 Corn Fields

地址:http://poj.org/problem?id=3254思路:状态压缩dp入门,对于每行的状态枚举,用二进制数来压缩保存。Code:#include<iostream>#include<cstring>using namespace std;const int MOD=1e8;const int MAX_N=13;const int ...

2018-09-26 21:37:49 170

原创 牛客小白月赛7-D 明七暗七

地址:https://www.nowcoder.com/acm/contest/190/D思路:数位DP+二分。利用数位DP可以求出从1到n的满足条件的个数,而对于求具体的数字,则可以用二分查找来求解dp[i][j][k]: 前i位余数为j,是否有7的个数 Code:#include<iostream>#include<cstring>usin...

2018-09-25 18:38:17 443

原创 Codeforces Round #511 (Div. 2)-C. Enlarge GCD

地址:http://codeforces.com/contest/1047/problem/C思路:从公共最大公约数+1开始枚举最大公约数 i 的元素个数s,取最大的s即可,枚举时将 i的倍数标记,标记的就不需要在枚举了。这样的时间复杂度为 O(max{ai}) Code :#include<iostream>#include<cstdio>using...

2018-09-25 12:35:00 290

原创 POJ-2778 DNA Sequence

地址:http://poj.org/problem?id=2778思路:同样是 AC自动机+矩阵快速幂。。Code :#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>#include<queue>using namesp...

2018-09-19 23:34:05 225

原创 ACM-ICPC 2018 焦作赛区网络预赛-B-Mathematical Curse

A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled in some mathematical curses. He studied hard until he reached ...

2018-09-19 22:04:41 239

原创 ACM-ICPC 2018 焦作赛区网络预赛-L- Poor God Water

God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him that some sequence of eating will make them poisonous.Every hour, God Water will eat one kind of fo...

2018-09-19 20:59:19 201

原创 ACM-ICPC 2018 焦作赛区网络预赛-K-Transport Ship

There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry the weight of V[i]V[i] and the number of the i^{th}ith kind of ship is 2^{C[i]} - 12C[i]−1. How many d...

2018-09-19 20:55:25 212

原创 ACM-ICPC 2018 焦作赛区网络预赛-G-Give Candies

地址:https://nanti.jisuanke.com/t/31716思路:手算出n=4,5的结果可以发现 答案就是 2^(n-1) ,但是这里的 n<=10^100000就算用快速幂也会超时,因此需要用费马小定理: a^(p-1)=1 (mod p) ,将 n对(MOD-1)取模后-1 ,然后再用快速幂即可Code :#include<cstdio>#i...

2018-09-19 20:50:54 228

原创 Wannafly挑战赛24-A,B,C

A-石子游戏:https://www.nowcoder.com/acm/contest/186/A思路:对于大于1的奇数分析,对于3 可以分为1,2,然后2与其他偶数合并,总共2次;考虑最后的偶数也与其他偶数合并,那么对于5可以分成 1,4 (2次)和 3,2 (4次),7和分为 1,6(2次),3,4(4次)和 5,2(6次)可以发现大于1的奇数的操作次数都是偶数次,那么说明奇数对于结果...

2018-09-18 17:10:10 480

原创 牛客小白月赛7题解

没想到身为菜鸟的我也能做7题,嘿嘿嘿2018/10/9 填坑完毕hhhA-送分题:https://www.nowcoder.com/acm/contest/190/A思路:该题直接交会爆内存。。。观察(跑几组数据)发现只要n大于等于2018001就都为 20182017,其他的则为 n+2017Code :#include<iostream>using name...

2018-09-16 00:11:40 759

原创 BZOJ-2115: [Wc2011] Xor

地址:https://www.lydsy.com/JudgeOnline/problem.php?id=2115思路:引用dalao的博客题解:https://www.cnblogs.com/ljh2000-jump/p/5869991.html Code:#include<iostream>#include<vector>#include&l...

2018-09-14 15:17:32 191

原创 HDU-3949 XOR

地址:http://acm.hdu.edu.cn/showproblem.php?pid=3949思路:先求出a[]的线性基f[],然后将线性基的每一位进行消除使其只有本身的那一位,在将f[i]中非0的全部移动f[1,m]中,m为非0的个数,这样对于第K个数,就是将K转为二进制中为1的f[]异或起来即可。另外还要处理有0的情况,这时需要将K-=1Code :#include&lt...

2018-09-13 20:15:24 250

原创 BZOJ-2460: [BeiJing2011]元素

2460: [BeiJing2011]元素Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 2485  Solved: 1292[Submit][Status][Discuss]Description  相传,在远古时期,位于西方大陆的 Magic Land 上,人们已经掌握了用魔法矿石炼制法杖的技术。那时人们就认识到,一个法杖的法力...

2018-09-13 15:37:20 203

原创 BZOJ-4260: Codechef REBXOR

地址:https://www.lydsy.com/JudgeOnline/problem.php?id=4260思路:求不相交的两个连续区间异或值的和的最大值,那么可以分别求出连续区间异或值的前缀最大值 L[i] 和后缀最大值 R[i],这样 Max=max{L[i]+R[i+1]}关于前缀最大值L[i],由于必须是连续区间,则可以利用前缀异或和 ml[i]来建立 01字典树。...

2018-09-12 21:01:09 248

原创 HDU-5536 Chip Factory

地址:http://acm.hdu.edu.cn/showproblem.php?pid=5536思路:题目限时9s,且题目输入数据的范围也提示的很明显,就是枚举 x=a[i]+a[j],建立a[]的01字典树,再去找x的最大异或和,对于i!=j!=z,因此还要排除掉 a[i],a[j]的影响,对于树的搜索中可判断a[i],a[j]是否还在当前路径上,在就需要sum[u]>在的个数s...

2018-09-12 18:47:14 304

原创 HDU-4825 Xor Sum

地址:http://acm.hdu.edu.cn/showproblem.php?pid=4825思路:01字典树,对于查询的数x,查找树中的最大异或值,同时保存路径的数即可,还有在初始化时记得用num来处理Code :#include<iostream>using namespace std;const int MAX_S=3200005;int n,Q,T...

2018-09-12 17:15:52 240

原创 CSU-1216: 异或最大值

地址:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1216思路:利用 01字典树,对于每一个数,由高位依次找与异或为1(即于当前位不同的数)的路径,保存其最大值即可Code :#include<iostream>#include<cstring>using namespace std;con...

2018-09-12 16:45:09 619

原创 ACM-ICPC 2018 徐州赛区网络预赛-G. Trace

There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy ) means the wave is a rectangle whose vertexes are ( 00 , 00 ), ( xx , 00 ), ( 00 , yy ), ( xx , yy ...

2018-09-10 13:39:36 264

原创 ACM-ICPC 2018 徐州赛区网络预赛- H. Ryuji doesn't want to study

Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, each book has its knowledge a[i]a[i].Unfortunately, the longer he learns, the fewer he gets.That m...

2018-09-10 13:25:38 221

原创 牛客练习赛26-D xor序列

地址:https://www.nowcoder.com/acm/contest/180/D思路:对于 x XOR p= y 那么 x XOR y= p, 即对于序列a[n]中元素判断是否可以 XOR出 p。这个可以用线性基来解决。。Code :#include<iostream>using namespace std;typedef long long LL;...

2018-09-10 13:13:36 285

原创 牛客练习赛26-C 城市规划

地址:https://www.nowcoder.com/acm/contest/180/C思路:这题要用O(n)的复杂度+读入优化才不会超时。对于线段[L,R],将右端点标记,同时保存以点R为右端点的线段的最大左端点值Max[R]由小到大遍历所有城市,同时用 l 表示已断开的城市的最大值,在遇到城市i被标记时,判断Max[R]与l的大小,若Max[R]大于l,则说明还有路径没有...

2018-09-08 19:39:05 292

原创 牛客练习赛26-B 烟花

地址:https://www.nowcoder.com/acm/contest/180/B思路:概率dp,dp[i][k]:前i种烟花产生k种颜色的概率dp[i][k]=dp[i-1][k-1]*p+dp[i-1][k]*(1-p);空间可以滚动数组优化Code :#include<iostream>using namespace std;const ...

2018-09-08 19:27:55 245

原创 CF-Educational Codeforces Round 50 (Rated for Div. 2) -C. Classy Numbers

地址:http://codeforces.com/contest/1036/problem/C思路:开始是想直接求1->L和1->R的个数,结果分析起来很麻烦,后来看别人的代码分析是先直接将所有的满足条件的数全部找出来。。。还是太差了QAQCode:#include<iostream>#include<algorithm>#include&...

2018-09-08 17:08:56 328

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除