技巧题
文章平均质量分 60
技巧题
浪漫些许潦草
这个作者很懒,什么都没留下…
展开
-
nyoj 找球号(二)
找球号(二)在某一国度里流行着一种游戏。游戏规则为:现有一堆球中,每个球上都有一个整数编号i(0<=i<=100000000),编号可重复,还有一个空箱子,现在有两种动作:一种是"ADD",表示向空箱子里放m(0<m<=100)个球,另一种是"QUERY”,表示说出M(0<M<=100)个随机整数ki(0<=ki<=100000100),分别判断编号为ki 的球是否在这个空箱子中(存在原创 2016-11-22 14:16:34 · 570 阅读 · 0 评论 -
zstu KI的斐波那契
KI的斐波那契DescriptionKI十分喜欢美丽而优雅的斐波那契数列,最近他新认识了一种斐波那契字符串,定义如下f (0) = b, f (1) = a,f (2) = f (1) + f (0) = ab,f (3) = f (2) + f (1) = aba,f (4) = f (3) + f (2) = abaab,......KI想知道 f (n转载 2016-11-23 20:34:53 · 605 阅读 · 0 评论 -
6个变态的C语言Hello World程序
6个变态的C语言Hello World程序原文链接:http://coolshell.cn/articles/914.html/comment-page-3#comment-88949下面的六个程序片段主要完成这些事情:输出Hello, World 混乱C语言的源代码 下面的所有程序都可以在GCC下编译通过,只有最后一个需要动用C++的编译器g++才能编程通过。1.转载 2016-12-06 15:06:21 · 720 阅读 · 0 评论 -
1个数的二进制中1的最小位数的位置
神奇的二进制运算代码:#include#includeusing namespace std;int main(){ int n; cin>>n; cout<<log2(n&(-n))+1<<endl;}比如说要找8的二进制中1的最小位数的位置首先,8的二进制表示为1000,很明显可以看出1在第四位,,不过,,,答案就是4.。还有一个代码原创 2016-12-17 12:55:55 · 1199 阅读 · 0 评论 -
Codeforces Round #384 B. Chloe and the sequence
Chloe and the sequence原题链接:http://codeforces.com/problemset/problem/743/BChloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad原创 2016-12-17 12:39:06 · 644 阅读 · 0 评论 -
nyoj 士兵杀敌(一)(树状数组)
士兵杀敌(一)描述南将军手下有N个士兵,分别编号1到N,这些士兵的杀敌数都是已知的。小工是南将军手下的军师,南将军现在想知道第m号到第n号士兵的总杀敌数,请你帮助小工来回答南将军吧。注意,南将军可能会问很多次问题。输入只有一组测试数据第一行是两个整数N,M,其中N表示士兵的个数(1随后的一行是N个整数,ai表示第i号士兵杀敌数目。(0转载 2016-11-09 21:37:07 · 383 阅读 · 0 评论 -
Codeforces Round #387 (Div. 2) Servers
Servers原题链接:http://codeforces.com/problemset/problem/747/CThere are n servers in a laboratory, each of them can perform tasks. Each server has a unique id — integer from 1 to n.It is原创 2016-12-20 08:46:37 · 498 阅读 · 0 评论 -
hdu 下沙小面的(2)(DFS)
下沙小面的(2)Problem Description前文再续,书接上一题。话说当上小面的司机的Lele在施行他的那一套拉客法则以后,由于走的路线太长,油费又贵,不久便亏本了。(真可怜~)于是他又想了一个拉客的办法。对于每一次拉客活动,他一次性把乘客都拉上车(当然也不会超过7个,因为位置只有7个)。然后,Lele计算出一条路线(出于某些目的,Lele只把车上乘客的目原创 2017-01-08 20:37:06 · 433 阅读 · 0 评论 -
hdu Humble Numbers(打表)
Humble NumbersProblem DescriptionA number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25,原创 2017-01-10 19:48:00 · 543 阅读 · 0 评论 -
hdu Eddy's research II(递推,找规律,打表)
Eddy's research IIProblem DescriptionAs is known, Ackermann function plays an important role in the sphere of theoretical computer science. However, in the other hand, the dramatic fast in原创 2017-01-12 19:09:16 · 438 阅读 · 0 评论 -
poj Babelfish(二分||map)
BabelfishDescriptionYou have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you u原创 2017-02-19 16:53:29 · 460 阅读 · 0 评论 -
nyoj 汉诺塔(一)
汉诺塔(一)描述 在印度,有这么一个古老的传说:在世界中心贝拿勒斯(在印度北部)的圣庙里,一块黄铜板上插着三根宝石针。印度教的主神梵天在创造世界的时候,在其中一根针上从下到上地穿好了由大到小的64片金片,这就是所谓的汉诺塔。不论白天黑夜,总有一个僧侣在按照下面的法则移动这些金片:一次只移动一片,不管在哪根针上,小片必须在大片上面。僧侣们预言,当所有的金片都从梵天穿好的那根针上移到另外一转载 2016-11-05 11:57:07 · 536 阅读 · 0 评论 -
int型整数的最大值和最小值
int型整数的最大值和最小值两种方法:1.#include #include int main(){ int i = sizeof(int); printf("max:%lld",(long long)pow(2,i*8-1)-1); printf("\n"); printf("min:%lld",-(long long)pow(2,i转载 2016-11-03 21:16:52 · 3993 阅读 · 0 评论 -
C++ int转string
C++ int转string第一种方式#include #include using namespace std;int main(){ int n = 65535; char t[256]; string s; sprintf(t, "%d", n); s = t; cout << s << endl; ret转载 2016-11-18 17:01:26 · 397 阅读 · 0 评论 -
动态规划之01背包问题
01背包01背包的状态转换方程 f[i,j] = Max{ f[i-1,j-Wi]+Pi( j >= Wi ), f[i-1,j] }f[i,j]表示在前i件物品中选择若干件放在承重为 j 的背包中,可以取得的最大价值。Pi表示第i件物品的价值。决策:为了背包中物品总价值最大化,第 i件物品应该放入背包中吗 ?题目描述:有编号分别为a,b,c,d,原创 2016-11-19 14:42:47 · 768 阅读 · 0 评论 -
前缀、中缀、后缀表达式
前缀、中缀、后缀表达式博客转载自:http://blog.csdn.net/antineutrino/article/details/6763722/关键字:概念, 前缀表达式, 前缀记法, 中缀表达式, 中缀记法, 波兰式, 后缀表达式, 后缀记法, 逆波兰式它们都是对表达式的记法,因此也被称为前缀记法、中缀记法和后缀记法。它们之间的区别在于运算符相对与操作数的位置不同:前缀表达式的转载 2016-12-06 17:16:15 · 414 阅读 · 0 评论 -
同余模定理
同余模定理定义:• 所谓的同余,顾名思义,就是许多的数被一个数d去除,有相同的余数。d数学上的称谓为模。如a=6,b=1,d=5,则我们说a和b是模d同余的。因为他们都有相同的余数1。• 数学上的记法为:• a≡ b(mod d)• 可以看出当n• (1) a和b是模d同余的.•转载 2016-12-24 21:31:38 · 773 阅读 · 0 评论 -
hdu 叠筐
叠筐Description需要的时候,就把一个个大小差一圈的筐叠上去,使得从上往下看时,边筐花色交错。这个工作现在要让计算机来完成,得看你的了。Input输入是一个个的三元组,分别是,外筐尺寸n(n为满足0Output输出叠在一起的筐图案,中心花色与外筐花色字符从内层起交错相叠,多筐相叠时,最外筐的角总是被打磨掉。叠筐与叠转载 2016-11-07 18:44:22 · 559 阅读 · 0 评论 -
树状数组
基本概念:假设数组a[1..n],那么查询a[1]+...+a[n]的时间是log级别的,而且是一个在线的数据结构,支持随时修改某个元素的值,复杂度也为log级别。来观察这个图:令这棵树的结点编号为C1,C2...Cn。令每个结点的值为这棵树的值的总和,那么容易发现:C1 = A1C2 = A1 + A2C3 = A3C4 = A1 + A2原创 2016-11-15 08:13:24 · 409 阅读 · 0 评论 -
poj 食物链(种类并查集)(思路)
食物链Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。原创 2017-03-02 20:32:03 · 1192 阅读 · 0 评论 -
CodeForces - 698B Fix a Tree(并查集)
Fix a TreeA tree is an undirected connected graph without cycles.Let's consider a rooted undirected tree with n vertices, numbered 1 through n. There are many ways to represent such a tr原创 2017-03-17 10:37:38 · 572 阅读 · 0 评论 -
hdu 5317 RGCDQ(数论素筛)
RGCDQProblem DescriptionMr. Hdu is interested in Greatest Common Divisor (GCD). He wants to find more and more interesting things about GCD. Today He comes up with Range Greatest Common Di原创 2017-03-15 17:22:01 · 721 阅读 · 0 评论 -
poj Parity game(带权并查集)(hash离散化)
Parity gameDescriptionNow and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for ex原创 2017-03-06 20:14:14 · 632 阅读 · 2 评论 -
zoj Connections in Galaxy War(逆向并查集)
Connections in Galaxy WarIn order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to exchange messages. However, when the Galaxy War原创 2017-03-07 21:52:47 · 1228 阅读 · 0 评论 -
SCU 4488 king's trouble II(dp||枚举)
king's trouble IIDescriptionLong time ago, a king occupied a vast territory.Now there is a problem that he worried that he want to choose a largest square of his territory to build a palace.原创 2017-03-18 18:11:39 · 650 阅读 · 0 评论 -
hdu 0 or 1(最短路spfa)(本质,抽象)
0 or 1Problem DescriptionGiven a n*n matrix Cij (1ij (1Besides,Xij meets the following conditions:1.X12+X13+...X1n=12.X1n+X2n+...Xn-1n=13.for each i (1ki (1ij (1For examp原创 2017-02-27 13:47:56 · 740 阅读 · 0 评论 -
poj 棋盘问题(经典DFS)(枚举)
棋盘问题Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,原创 2016-12-22 21:48:47 · 1468 阅读 · 0 评论 -
ZOJ 3710 Friends(枚举)
FriendsAlice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less than k friends in common, they will become friends in several day原创 2017-04-07 07:55:26 · 572 阅读 · 0 评论 -
nyoj 第k个互质数(二分+容斥原理)
第k个互质数描述两个数的a,b的gcd为1,即a,b互质,现在给你一个数m,你知道与它互质的第k个数是多少吗?与m互质的数按照升序排列。输入输入m ,k (1输出输出第k个数。样例输入10 110 210 3样例输出137思路:首先要知道: 在[1,m]之间与m互质的数的个数=[1,m]之间的原创 2017-03-20 10:02:29 · 955 阅读 · 1 评论 -
【codeforces 782B】The Meeting Place Cannot Be Changed(二分)
The Meeting Place Cannot Be ChangedThe main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in原创 2017-03-07 15:41:25 · 544 阅读 · 0 评论 -
CodeForces - 376C Divisible by Seven(数论:同余定理)(找规律)
Divisible by SevenYou have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulti原创 2017-03-12 21:38:16 · 618 阅读 · 0 评论 -
CodeForces - 731C Socks(并查集)(贪心)
SocksArseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Ars原创 2017-03-12 15:59:51 · 1125 阅读 · 0 评论 -
ZOJ 3715 Kindergarten Election(枚举+贪心)
Kindergarten ElectionAt the beginning of the semester in kindergarten, the n little kids (indexed from 1 to n, for convenience) in class need to elect their new leader.The ith kid will vote for his bes原创 2017-04-07 21:55:10 · 659 阅读 · 0 评论 -
CodeForces - 711D Directed Roads(dfs判环)
Directed RoadsZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of n towns numbered from 1 to n.There are n directed roads in the Udayland. i-th原创 2017-03-22 19:26:29 · 627 阅读 · 0 评论 -
poj 1064 Cable master
Cable masterDescriptionInhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever原创 2017-03-22 12:13:52 · 439 阅读 · 0 评论 -
hdu 4848 Wow! Such Conquering!(floyd+dfs)
Wow! Such Conquering!Problem Description There are n Doge Planets in the Doge Space. The conqueror of Doge Space is Super Doge, who is going to inspect his Doge Army on all Doge Planets. The inspectio原创 2017-03-31 21:07:23 · 608 阅读 · 0 评论 -
FZU 1076 穿越沙漠(逆推建模)(数学)
穿越沙漠Problem Description一辆吉普车来到x公里宽的沙漠边沿A点,吉普车的耗油量为1升/公里,总装油量为500升。通常,吉普车必须用自身油箱中的油在沙漠中设置若干个临时储油点,才能穿越沙漠的。假设在沙漠边沿A点有充足的汽油可供使用,那么吉普车从A点穿过这片沙漠到达终点B,至少要耗多少升油。请编写一个程序,计算最少的耗油量(精确到小数点后3位)。 (1)假设吉普车在沙漠中原创 2017-03-24 18:45:27 · 6749 阅读 · 0 评论 -
线性筛法求素数
线性筛法求素数博客转载自:http://www.cnblogs.com/grubbyskyer/p/3852421.html题目:给出一个正整数n,打印出所有从1~n的素数(即质数); 关键是要找出一个判断一个正整数n是否为素数的方法... 傻瓜解法--n,n/2 1 #include 2 int main() 3 { 4 int i,n;转载 2016-11-26 22:19:41 · 868 阅读 · 1 评论 -
NBUT 1225 NEW RDSP MODE I(找规律)(快速幂)
NEW RDSP MODE I问题描述Little A has became fascinated with the game Dota recently, but he is not a good player. In all the modes, the rdsp Mode is popular on online, in this mode, little A always loses gam原创 2017-04-10 19:33:47 · 500 阅读 · 0 评论 -
Codeforces 763B Timofey and rectangles(四色定理)(思维)
Timofey and rectanglesOne of Timofey’s birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the原创 2017-03-26 07:43:04 · 625 阅读 · 0 评论