自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Beyond the Sora

拖延症晚期

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

原创 Lightoj1238——Power Puff Girls(bfs)

The city of Townsville! This nice city is the home for the power puff girls - Blossom, Bubbles and Buttercup. To introduce their personality we can sing a song:Blossom, commander and the leader; Bubbl

2017-04-12 18:43:47 1447

原创 Lightoj1174——Commandos(双向最短路)

A group of commandos were assigned a critical task. They are to destroy an enemy head quarter. The enemy head quarter consists of several buildings and the buildings are connected by roads. The command

2017-04-12 16:52:28 916

原创 Lightoj1019——Brush (V)(最短路)

Tanvir returned home from the contest and got angry after seeing his room dusty. Who likes to see a dusty room after a brain storming programming contest? After checking a bit he found that there is no

2017-04-12 16:02:54 307

原创 Lightoj1261——1261 - K-SAT Problem(模拟)

SAT was the first known NP-complete problem. The problem remains NP-complete even if all expressions are written in conjunctive normal form with 3 variables per clause (3-CNF), yielding the 3-SAT probl

2017-04-12 15:00:08 679

原创 poj2002——Squares(hash)

DescriptionA square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that rotating about its centre by 90 degrees gives the same po

2017-04-11 18:15:50 1000

原创 poj1845——Sumdiv(数论+幂的因子和)

DescriptionConsider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901). InputThe only line contains the two n

2017-04-11 16:26:25 973

原创 poj1011——Sticks(dfs+剪枝)

DescriptionGeorge took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks h

2017-04-11 15:18:52 582 1

原创 poj1416——Shredding Company(dfs)

DescriptionYou have just been put in charge of developing a new shredder for the Shredding Company Although a “normal” shredder would just shred sheets of paper into little pieces so that the contents

2017-04-11 12:01:18 1068

原创 CSU1113——Updating a Dictionary(STL)

Description In this problem, a dictionary is collection of key-value pairs, where keys are lower-case letters, and values are non-negative integers. Given an old dictionary and a new dictionary, find

2017-04-11 09:25:14 811

原创 zoj3957——Knuth-Morris-Pratt Algorithm(KMP)

In computer science, the Knuth-Morris-Pratt string searching algorithm (or KMP algorithm) searches for occurrences of a “word” W within a main “text string” S by employing the observation that when a m

2017-04-09 22:21:03 743

原创 zoj3950——How Many Nines(日期模拟)

If we represent a date in the format YYYY-MM-DD (for example, 2017-04-09), do you know how many 9s will appear in all the dates between Y1-M1-D1 and Y2-M2-D2 (both inclusive)?Note that you should take

2017-04-09 22:02:46 1276 5

原创 hdu1102——Constructing Roads(prim)

Problem Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connect

2017-04-09 10:08:38 646

原创 YTU1302——泊松分酒(bfs)

Description泊松是法国数学家、物理学家和力学家。他一生致力科学事业,成果颇多。有许多著名的公式定理以他的名字命名,比如概率论中著名的泊松分布。有一次闲暇时,他提出过一个有趣的问题,后称为:“泊松分酒”。在我国古代也提出过类似问题,遗憾的是没有进行彻底探索,其中流传较多是:“韩信走马分油”问题。有3个容器,容量分别为12升,8升,5升。其中12升中装满油,另外两个空着。要求你只用3个容器操作

2017-04-07 19:23:37 1716

原创 蓝桥杯算法提高——最大乘积

问题描述   对于n个数,从中取出m个数,如何取使得这m个数的乘积最大呢? 输入格式   第一行一个数表示数据组数   每组输入数据共2行:   第1行给出总共的数字的个数n和要取的数的个数m,1<=n<=m<=15,   第2行依次给出这n个数,其中每个数字的范围满足:a[i]的绝对值小于等于4。 输出格式   每组数据输出1行,为最大的乘积。 样例输入 1 5 5 1 2

2017-04-06 17:12:38 831

原创 蓝桥杯算法提高——6-17复数四则运算

设计复数库,实现基本的复数加减乘除运算。   输入时只需分别键入实部和虚部,以空格分割,两个复数之间用运算符分隔;输出时按a+bi的格式在屏幕上打印结果。参加样例输入和样例输出。   注意考虑特殊情况,无法计算时输出字符串”error”。 样例输入 2 4 * -3 2 样例输出 -14-8i 样例输入 3 -2 + -1 3 样例输出 2+1i算是比较全面了,先存着防止以后再去

2017-04-05 16:47:25 640

原创 蓝桥杯算法提高——概率计算(概率dp)

问题描述   生成n个∈[a,b]的随机整数,输出它们的和为x的概率。 输入格式   一行输入四个整数依次为n,a,b,x,用空格分隔。 输出格式   输出一行包含一个小数位和为x的概率,小数点后保留四位小数 样例输入 2 1 3 4 样例输出 0.3333 数据规模和约定   对于50%的数据,n≤5.   对于100%的数据,n≤100,b≤100.#include <i

2017-04-05 16:17:59 1419 1

原创 蓝桥杯算法提高——日期计算

问题描述   已知2011年11月11日是星期五,问YYYY年MM月DD日是星期几?注意考虑闰年的情况。尤其是逢百年不闰,逢400年闰的情况。 输入格式   输入只有一行   YYYY MM DD 输出格式   输出只有一行   W 数据规模和约定   1599 <= YYYY <= 2999   1 <= MM <= 12   1 <= DD <= 31,且确保测试样例中YY

2017-04-05 15:22:30 764

原创 蓝桥杯算法提高——扶老奶奶过街(逻辑推理)

一共有5个红领巾,编号分别为A、B、C、D、E,老奶奶被他们其中一个扶过了马路。  五个红领巾各自说话:  A :我和E都没有扶老奶奶  B :老奶奶是被C和E其中一个扶过大街的  C :老奶奶是被我和D其中一个扶过大街的  D :B和C都没有扶老奶奶过街  E :我没有扶老奶奶  已知五个红领巾中有且只有2个人说的是真话,请问是谁扶这老奶奶过了街?  若有多个答案,在一行中输出,编号之间用空格隔开

2017-04-04 16:17:30 1357

原创 蓝桥杯算法提高——学霸的迷宫(bfs)

问题描述   学霸抢走了大家的作业,班长为了帮同学们找回作业,决定去找学霸决斗。但学霸为了不要别人打扰,住在一个城堡里,城堡外面是一个二维的格子迷宫,要进城堡必须得先通过迷宫。因为班长还有妹子要陪,磨刀不误砍柴功,他为了节约时间,从线人那里搞到了迷宫的地图,准备提前计算最短的路线。可是他现在正向妹子解释这件事情,于是就委托你帮他找一条最短的路线。 输入格式   第一行两个整数n, m,为迷宫的

2017-04-04 15:44:36 698

原创 蓝桥杯算法提高——上帝造题五分钟(线段树+区间最小值)

问题描述   第一分钟,上帝说:要有题。于是就有了L,Y,M,C   第二分钟,LYC说:要有向量。于是就有了长度为n写满随机整数的向量   第三分钟,YUHCH说:要有查询。于是就有了Q个查询,查询向量的一段区间内元素的最小值   第四分钟,MZC说:要有限。于是就有了数据范围   第五分钟,CS说:要有做题的。说完众神一哄而散,留你来收拾此题 输入格式   第一行两个正整数n和Q,

2017-04-03 18:43:50 799

原创 hdu5067——Harry And Dig Machine(dfs+剪枝)

Problem Description As we all know, Harry Porter learns magic at Hogwarts School. However, learning magical knowledge alone is insufficient to become a great magician. Sometimes, Harry also has to g

2017-04-02 16:30:58 794

原创 hdu5066——Harry And Physical Teacher(物理)

Problem Description As we all know, Harry Porter learns magic at Hogwarts School. However, learning magical knowledge alone is insufficient to become a great magician. Sometimes, Harry also has to gai

2017-04-02 16:28:26 777

原创 hdu5062——Beautiful Palindrome Number(模拟)

Problem Description A positive integer x can represent as (a1a2…akak…a2a1)10(a_1a_2 \ldots a_ka_k \ldots a_2a_1)_{10} or (a1a2…ak−1akak−1…a2a1)10(a_1a_2 \ldots a_{k-1}a_ka_{k-1} \ldots a_2a_1)_{10} of

2017-04-02 16:18:33 628

原创 hdu5059——Help him(字符串处理)

Problem Description As you know, when you want to hack someone’s program, you must submit your test data. However sometimes you will submit invalid data, so we need a data checker to check your data.

2017-04-02 16:15:22 807

原创 hdu5058——So easy(STL)

Problem Description Small W gets two files. There are n integers in each file. Small W wants to know whether these two files are same. So he invites you to write a program to check whether these two f

2017-04-02 16:10:12 544

原创 hdu1520——Anniversary party(树形dp)

Problem Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor

2017-04-01 19:59:29 737

原创 poj2342——Anniversary party(树形dp)

DescriptionThere is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation

2017-03-31 21:24:33 574

原创 蓝桥杯算法提高——盾神与条状项链(链表)

问题描述   有一天,盾神捡到了好多好多五颜六色的珠子!他心想这些珠子这么漂亮,可以做成一条项链然后送给他心仪的女生~于是他用其中一些珠子做成了长度为n的项链。当他准备把项链首尾相接的时候,土方进来了。   “哇这么恶心的项链你也做得出来!!!”   盾神自知审美不是他的长项,于是他很谦虚地请教土方,怎么才能把项链做得漂亮。   “这个嘛~首先你要在这里加上一个这种颜色的珠子,然后在这里去掉

2017-03-31 17:48:03 553 1

原创 蓝桥杯算法提高——拿糖果(数学+dp)

问题描述   妈妈给小B买了N块糖!但是她不允许小B直接吃掉。   假设当前有M块糖,小B每次可以拿P块糖,其中P是M的一个不大于根号下M的质因数。这时,妈妈就会在小B拿了P块糖以后再从糖堆里拿走P块糖。然后小B就可以接着拿糖。   现在小B希望知道最多可以拿多少糖。 输入格式   一个整数N 输出格式   最多可以拿多少糖 样例输入 15 样例输出 6 数据规模和约定

2017-03-31 15:30:21 1286

原创 lightoj1094——Farthest Nodes in a Tree(dfs+最长路径)

Given a tree (a connected graph with no cycles), you have to find the farthest nodes in the tree. The edges of the tree are weighted and undirected. That means you have to find two nodes in the tree wh

2017-03-30 20:49:33 630

原创 蓝桥杯算法提高——递推求值(矩阵快速幂)

问题描述   已知递推公式:  F(n, 1)=F(n-1, 2) + 2F(n-3, 1) + 5,  F(n, 2)=F(n-1, 1) + 3F(n-3, 1) + 2F(n-3, 2) + 3.  初始值为:F(1, 1)=2, F(1, 2)=3, F(2, 1)=1, F(2, 2)=4, F(3, 1)=6, F(3, 2)=5。   输入n,输出F(n, 1)和F(n, 2),由

2017-03-30 19:18:19 1164

原创 hdu4990——Reading comprehension(矩阵快速幂)

Read the program below carefully then answer the question. #pragma comment(linker, “/STACK:1024000000,1024000000”) #include < cstdio> #include < iostream> #include < cstring> #include < cmath

2017-03-30 18:19:19 607

原创 lightoj1311——Unlucky Bird(数学)

A bird was flying on a train line, singing and passing lazy times. After a while it saw a train coming from its behind, so, it speeded up a bit, but remained calm. After a while it saw another train co

2017-03-29 19:36:47 711

原创 poj3070——Fibonacci(矩阵快速幂)

DescriptionIn the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …An alt

2017-03-29 16:52:23 939

原创 蓝桥杯算法提高——队列操作(STL)

问题描述   队列操作题。根据输入的操作命令,操作队列(1)入队、(2)出队并输出、(3)计算队中元素个数并输出。 输入格式   第一行一个数字N。   下面N行,每行第一个数字为操作命令(1)入队、(2)出队并输出、(3)计算队中元素个数并输出。 输出格式   若干行每行显示一个2或3命令的输出结果。注意:2.出队命令可能会出现空队出队(下溢),请输出“no”,并退出。 样例输入

2017-03-28 19:15:42 747

原创 团体程序设计天梯赛——球队“食物链”(dfs+状态压缩)

某国的足球联赛中有N支参赛球队,编号从1至N。联赛采用主客场双循环赛制,参赛球队两两之间在双方主场各赛一场。联赛战罢,结果已经尘埃落定。此时,联赛主席突发奇想,希望从中找出一条包含所有球队的“食物链”,来说明联赛的精彩程度。“食物链”为一个1至N的排列{ T1 T2 … TN },满足:球队T1战胜过球队T2,球队T2战胜过球队T3,……,球队T(N-1)战胜过球队TN,球队TN战胜过球队T1。现在

2017-03-28 16:48:14 431

原创 团体程序设计天梯赛——红色警报(dfs)

战争中保持各个城市间的连通性非常重要。本题要求你编写一个报警程序,当失去一个城市导致国家被分裂为多个无法连通的区域时,就发出红色警报。注意:若该国本来就不完全连通,是分裂的k个区域,而失去一个城市并不改变其他城市之间的连通性,则不要发出警报。输入格式:输入在第一行给出两个整数N(0 << N \le≤ 500)和M(\le≤ 5000),分别为城市个数(于是默认城市从0到N-1编号)和连接两城市的通

2017-03-22 20:09:16 578

原创 团体程序设计天梯赛——玩转二叉树(遍历构造二叉树)

给定一棵二叉树的中序遍历和前序遍历,请你先将树做个镜面反转,再输出反转后的层序遍历的序列。所谓镜面反转,是指将所有非叶结点的左右孩子对换。这里假设键值都是互不相等的正整数。输入格式:输入第一行给出一个正整数N(\le≤30),是二叉树中结点的个数。第二行给出其中序遍历序列。第三行给出其前序遍历序列。数字间以空格分隔。输出格式:在一行中输出该树反转后的层序遍历的序列。数字间以1个空格分隔,行首尾不得有

2017-03-21 16:34:52 831

原创 团体程序设计天梯赛——排座位(dfs)

布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位。无论如何,总不能把两个死对头排到同一张宴会桌旁!这个艰巨任务现在就交给你,对任何一对客人,请编写程序告诉主人他们是否能被安排同席。输入格式:输入第一行给出3个正整数:N(\le≤100),即前来参宴的宾客总人数,则这些人从1到N编号;M为已知两两宾客之间的关系数;K为查询的条数。随后M行,每行给出一对宾客之间的关系,格式为:宾客1 宾客2 关系

2017-03-20 21:02:34 895

原创 hdu4994——Revenge of Nim(博弈)

Problem Description Nim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove

2017-03-19 22:43:31 545

空空如也

空空如也

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

TA关注的人

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