【HDOJ】1098 Ignatius's puzzle】的更多相关文章

数学归纳法,得证只需求得使18+ka被64整除的a.且a不超过65. #include <stdio.h> int main() { int i, j, k; while (scanf("%d", &k) != EOF) { j = ; ; i<; i++) { +k*i) % == ) { j = ; break; } } if (j) printf("%d\n", i); else printf("no\n"); }…
题目和1061非常相似,几乎可以复用. #include <stdio.h> ][]; int main() { int a, b; int i, j; ; i<; ++i) { buf[i][] = ; buf[i][] = i; ; j<; ++j) { buf[i][j] = buf[i][j-]*i%; ]) break; buf[i][]++; } } while (scanf("%d %d", &a, &b) != EOF) { i…
这道题目最开始完全不懂,后来百度了一下,原来是字典序.而且还是组合数学里的东西.看字典序的算法看了半天才搞清楚,自己仔细想了想,确实也是那么回事儿.对于长度为n的数组a,算法如下:(1)从右向左扫描,找到满足a[i]<a[i+1]的第一个i,也就是i = max{i|a[i]<a[i+1]},同时也意味着a[i+1]~a[n]是升序:(2)从右向左扫描,找到满足a[j]>a[i]的第一个j,也就是j = max{j|a[j]>a[i]},a[j]也是满足大于a[i]的最小数:(3)…
这道题搞了很久啊.搜索非常好的一道题.昨天想了2小时,以为是深搜,但后来发现深搜怎么也没法输出正确路径.今天拿宽搜试了一下,问题就是普通的队列宽搜没法得到当前时间最小值.看了一下讨论区,发现优先级队列.好久不用了,都忘记了.各种忘记,优先级队列排序都忘掉了.搞了好半天.最后还需要注意的是格式化输出,采用栈格式输出.需要保存每个节点的移动方向.并且注意若终点是怪兽,还是需要"Fight".这道题目感觉不是一道水题,还挺不错. #include <iostream> #incl…
Ignatius's puzzle Problem Description Ignatius is poor at math,he falls across a puzzle problem,so he has no choice but to appeal to Eddy. this problem describes that:f(x)=5x13+13*x5+ka*x,input a nonegative integer k(k<10000),to find the minimal none…
Problem Description Ignatius is poor at math,he falls across a puzzle problem,so he has no choice but to appeal to Eddy. this problem describes that:f(x)=5*x^13+13*x^5+k*a*x,input a nonegative integer k(k<10000),to find the minimal nonegative integer…
trie树.以puzzle做trie树内存不够,从puzzle中直接找串应该会TLE.其实可以将查询组成trie树,离线做.扫描puzzle时注意仅三个方向即可. /* 1857 */ #include <iostream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector>…
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到boundry,使得boundry * n_edge - sum_edge <= k/b, 或者建立s->t,然后不断extend s->t. /* 4729 */ #include <iostream> #include <sstream> #include <…
http://www.lydsy.com/JudgeOnline/problem.php?id=1098 显然答案是补图连通块..... 想到用并查集...可是连补图的边都已经...n^2了...怎么做.. 好神的题! 考虑我们是如何建补图和并查集:是不是都是先枚举一个点,然后标记能到达的点,然后没到达的点就是要连的边.最后在来一次并查集. 是吧.. 那么考虑:为什么要并查集...我们找到没到达的点就行了么...那么肯定就是在一个连通块,问题在于如何将整个连通块找出来.bfs! 考虑:我们之前放…
DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define rep(i,n) for(int i=0;i<n;++i) #define…