
dfs
文章平均质量分 60
Ren_Ivan
衡中oier,fight for furture
展开
-
bzoj 3629 聪明的燕姿 约数和+dfs
考试只筛到了30分,正解dfs......对于任意N=P1^a1*P2^a2*......*Pn^an,F(N)=(P1^0+P1^1+...+P1^a1)(P2^0+P2^1+...+P2^a2)*...*(Pn^0+Pn^1+...+Pn^an)从小到大枚举素数P,依次判定是否有K满足(P^0+P^1+...+P^K)|X有一些细节需要处理,比如当前S为某大素数+1......原创 2017-07-10 20:05:34 · 365 阅读 · 0 评论 -
bzoj 1064 假面舞会 图论??+dfs
有两种情况需要考虑1.链:可以发现对最终的k没有影响2.环:如果是真环(即1->2->3->4->1),可以看出所有可行解一定是该环的因数 假环呢??(1->2->3->4,1->5->4),可行解便是两条路的差值的因数So??对于每条边,正建1,反建-1,dfs,每出一个环,就计算gcd没有环呢??最小是3,最大是所有链加和喽#include#include#incl原创 2017-07-12 10:40:23 · 326 阅读 · 0 评论 -
noip 2015 斗地主 大爆搜!!!
反正肯定是大模拟但是每一个可以出的牌都搜一定不是最优的考虑最特殊的出牌方案:顺子(单,对,三)每一种方案再加上暴力贪心打出剩下的牌的步数#include#include#include#include#include#define N 35using namespace std;int a[N],num[N],n,T,ANS;void read(){ int原创 2017-07-31 15:01:48 · 388 阅读 · 0 评论 -
noip2011 玛雅游戏 大模拟
深搜+模拟需要剪枝:同一移动向右移了就不需要向左移了#include#include#include#include#includeusing namespace std;int n,bo[6][8],tot,a[6][6][8],b[6][3];bool boo;int print(int x){ printf("\n"); for(int i=0;i<原创 2017-07-27 21:03:46 · 552 阅读 · 0 评论 -
[SCOI2005]栅栏 二分+dfs
这个题真的是太nb了,各种骚二分答案,肯定要减最小的mid个,从大往小搜每一个木板,从大往小枚举所用的木材当当前木材比最短的木板还短,就扔到垃圾堆里,并记录waste,当 waste+sum>tot 时,return#include#include#include#include#include#define N 2005using namespace std;int n原创 2017-09-17 15:21:36 · 409 阅读 · 0 评论