自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(95)
  • 收藏
  • 关注

原创 uva 11408 Count DePrimes 求素数变式

A number is called a DePrime if the sum of its prime factors is a prime number. Given a and b count the number of DePrimes xi such that a ≤ xi ≤ b. Input Each line contains a and b in the format ‘a...

2018-06-06 09:30:17 279

原创 欧拉函数

uva 10299 计算一个给定数的欧拉函数(1~n-1中和n互质的数的个数) 欧拉函数:φ(n)= n (1 - 1/p1)(1 - 1/p2)(1 - 1/p3)…*(1 - 1/pt);这里利用筛法打表计算出50000内的素数,因为数据范围是1000000000内的#include <iostream>#include <cstring>using n...

2018-03-26 18:05:49 211

原创 uva 531 Compromise

In a few months the European Currency Union will become a reality. However, to join the club, the Maastricht criteria must be ful lled, and this is not a trivial task for the countries (maybe except f...

2018-03-14 11:11:25 184

原创 uva 10192 Vacation

You are planning to take some rest and to go out on vacation, but you really don’t know which cities you should visit. So, you ask your parents for help. Your mother says “My son, you MUST visit Paris...

2018-03-14 10:37:51 154

原创 uva 10405 Longest Common Subsequence

求两个字符串x,y的最长公共子序列 dp[i][j]表示x的前缀xi和y的前缀yj的LCS的长度 状态转移方程为: if(a[i]==b[j]) dp[i][j]=dp[i-1][j-1]+1; else dp[i][j]=Max{dp[i-1][j],dp[i],[j-1]};#include <iostream>#include <cstring&...

2018-03-14 10:31:44 128

原创 算法训练 操作格子

问题描述 有n个格子,从左到右放成一排,编号为1-n。共有m次操作,有3种操作类型:1.修改一个格子的权值,2.求连续一段格子权值和,3.求连续一段格子的最大值。对于每个2、3操作输出你所求出的结果。输入格式 第一行2个整数n,m。接下来一行n个整数表示n个格子的初始权值。接下来m行,每行3个整数p,x,y,p表示操作类型,p=1时表示修改格子x的权值为y,p=

2018-02-05 18:24:21 190

原创 算法训练 最短路

问题描述 给定一个n个顶点,m条边的有向图(其中某些边权可能为负,但保证没有负环)。请你计算从1号点到其他点的最短路(顶点从1到n编号)。输入格式 第一行两个整数n, m。接下来的m行,每行有三个整数u, v, l,表示u到v有一条长度为l的边。输出格式 共n-1行,第i行表示1号点到i+1号点的最短路。 样例输入 3 3 1 2 -1 2 3 -1 3 1 2 样例

2018-01-18 09:39:04 487 1

原创 算法训练 安慰奶牛

问题描述 Farmer John变得非常懒,他不想再继续维护供奶牛之间供通行的道路。道路被用来连接N个牧场,牧场被连续地编号为1到N。每一个牧场都是一个奶牛的家。FJ计划除去P条道路中尽可能多的道路,但是还要保持牧场之间 的连通性。你首先要决定那些道路是需要保留的N-1条道路。第j条双向道路连接了牧场Sj和Ej(1 输入格式 第1行包含两个整数N和P。接下来N行,每行包含一个整数Ci。

2018-01-16 14:23:43 178

原创 poj 2406 Power Strings

Description Given two strings a and b we define a*b to be their concatenation. For example, if a = “abc” and b = “def” then a*b = “abcdef”. If we think of concatenation as multiplication, exponentiati

2017-11-21 11:38:41 142

原创 HDU 1711 Number Sequence

Problem Description Given two sequences of numbers : a[1], a[2], …… , a[N], and b[1], b[2], …… , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K

2017-11-19 19:42:26 154

原创 uva 10080 Gopher II【匈牙利算法】

The gopher family, having averted the canine threat, must face a new predator. The are n gophers and m gopher holes, each at distinct (x,y) coordinates. A hawk arrives and if a gopher does not reach a

2017-11-17 12:06:40 490

原创 uva 670 The dog task

匈牙利算法,将狗的兴趣点与人走的每段路作二部图(即图的左边是点,右边是边),求出该二部图对于狗的兴趣点的最大匹配数,再加上人必经的点数,就是狗的路线。#include <iostream>#include <cmath>#include <vector>#include <cstring>using namespace std;const int Maxn=105;int N,M;do

2017-11-16 10:37:13 174

原创 UVA 10092 The Problem with the Problemsetter

The number of students interested to participate in this year’s Intra-BUET Programming Contest is huge. Since it is very difficult to accommodate such a large number of students in our labs, we have de

2017-11-15 22:08:39 477

原创 poj 2352 Stars

题意: 在坐标上有n个星星,如果某个星星左下位置有a个星星,就表示这个星星属于level a 星星坐标输入按照y递增,如果y相同则x递增,求出所有level水平的星星数量#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int Maxn=32005;const int N=1

2017-10-14 22:06:24 148

原创 poj 3468 A Simple Problem with Integers

You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum

2017-10-14 21:40:47 172

原创 UVA 536 Tree Recovery

题意: 给出一个二叉树的前序遍历和中序遍历,输出其后序遍历 思路: 利用递归,将前序数组和中序数组不断划分,不断将前序数组的第一个值存入后序数组#include <iostream>#include <string>using namespace std;string per,in,pos;void initial(){ pos.clear();//清空字符串}void

2017-10-11 22:34:28 211

原创 UVA 107 The Cat in the Hat

(An homage to Theodore Seuss Geisel) The Cat in the Hat is a nasty creature, But the striped hat he is wearing has a rather nifty feature. With one ick of his wrist he pops his top o . Do you know

2017-10-11 22:27:35 197

原创 UVA 122 Trees on the level

题意: 给出二叉树的结点值及其路径,按从上到下,从左到右的顺序输出二叉树各个结点值,若没有根节点或有重复,输出“not complete” 思路: ‘L’字典序<‘R’,因此输出顺序即为各个结点按路径从小到大排序。 建立结构体Pair,储存每个节点的值及其路径,并重载运算符‘<’。用vector存储各个结点,利用sort()排序,默认为升序 注意输入格式#include <iostream

2017-10-11 22:17:40 188

原创 UVA 10926 How Many Dependencies?

In this problem you will need to find out which task has the most number of dependencies. A task A depends on another task B if B is a direct or indirect dependency of A. For example, if A depends on

2017-10-03 14:45:14 239

原创 UVA 10142 Australian Voting

Australian ballots require that the voter rank the candidates in order of choice. Initially only the first choices are counted and if one candidate receives more than 50% of the vote, that candidate is

2017-10-03 14:20:41 410

原创 UVA 572 Oil Deposits

The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the

2017-10-03 14:06:34 204

原创 UVA 532 Dungeon Master

You are trapped in a 3D dungeon and need to nd the quickest way out! The dungeon is composed of unit cubes which may or may not be lled with rock. It takes one minute to move one unit north, south, e

2017-10-03 13:48:29 204

原创 UVA 439 Knight Moves

A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to nd the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard

2017-10-02 17:40:45 184

原创 UVA 417 Word Index

Encoding schemes are often used in situations requiring encryption or information storage/transmission economy. Here, we develop a simple encoding scheme that encodes particular types of words with ve

2017-10-02 17:30:08 364

原创 UVA 352 The Seasonal War

The inhabitants of Tigerville and Elephantville are engaged in a seasonal war. Last month, Elephantville successfully launched and orbited a spy telescope called the Bumble Scope. The purpose of the Bu

2017-10-02 17:15:09 412

原创 UVA 336 A Node Too Far

题意: 给出点的个数及各个点之间的联通情况,输出从某点开始沿联通图路线走n步后不能到达的点的个数,0 0结束 思路: 用bfs搜索每个点#include <iostream>#include <map>#include <queue>#include <vector>using namespace std;//int vis[1000];int N,T,cnt;map<int,v

2017-10-02 17:09:24 353 1

原创 UVA 260 Il Gioco dell'X

题意: 黑白两方下棋,必有一人胜出,若黑棋能从第一行走到最后一行则Black胜出,若白棋能从能从第一列走到最后一列则White胜出 思路: 只需判断Black是否胜出,用dfs搜索黑棋能否能从第一行走到最后一行#include <iostream>using namespace std;int N,flag=0;int dx[]={1,0,1,0,-1,-1};//记录六个方向int

2017-10-02 16:55:56 190

原创 UVA 170 Clock Patience

题意: 将牌依次分成13堆,牌面朝下,按从1到13的顺序发牌,然后从第K堆第一张开始翻牌,然后将该牌放在这一堆的最下面,面朝上,接着翻牌面上显示的数字那一堆的第一张面朝下的牌,重复此过程,直到所有牌都面朝上,输出翻牌的次数以及最后一次翻的牌 思路: 用队列数组保存13堆牌,用结构体存储每张牌的面值、花色、面朝上/朝下,然后模拟翻牌过程#include <iostream>#include

2017-10-02 16:47:33 279

原创 UVA 144 Student Grants

The Government of Impecunia has decided to discourage tertiary students by making the payments of tertiary grants a long and time-consuming process. Each student is issued a student ID card which has a

2017-10-02 16:23:23 477

原创 UVA 469 Wetlands of Florida

A construction company owns a large piece of real estate within the state of Florida. Recently, the company decided to develop this property. Upon inspection of the property, however, it was revealed t

2017-10-02 15:55:16 595

原创 POJ 2062 Card Game Cheater

Adam and Eve play a card game using a regular deck of 52 cards. The rules are simple. The players sit on opposite sides of a table, facing each other. Each player gets k cards from the deck and, after

2017-10-02 14:53:13 297

原创 POJ 2051 Argus

A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, financial tickers, on-line auctions, and transaction logs such as Web usage log

2017-10-02 14:36:32 195

原创 uva 10596 Morning Walk

Kamal is a Motashota guy. He has got a new job in Chittagong. So, he has moved to Chittagong from Dinajpur. He was getting fatter in Dinajpur as he had no work in his hand there. So, moving to Chittago

2017-10-02 14:20:53 162

原创 UVA 10452 Marcus

“First, the breath of God. Only the penitent man will pass. Second, the Word of God, Only in the footsteps of God will he proceed. Third, the Path of God, Only in the leap from the lion’s head wil

2017-09-24 12:30:34 473

原创 UVA 10336 Rank the Languages

You might have noticed that English and Spanish are spoken in many areas all over the world. Now it would be nice to rank all languages according to the number of states where they are spoken. You’re

2017-09-24 11:40:36 426

原创 UVA 10539 Almost Prime

Almost prime numbers are the non-prime numbers which are divisible by only a single prime number. In this problem your job is to write a program which finds out the number of almost prime numbers withi

2017-09-23 19:04:21 311

原创 UVA 10706 Number Sequence

A single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2 … Sk. Each group Sk consists of a sequence of positive integer nu

2017-09-23 18:27:28 234

原创 uva 315 Network

A Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting several places numbered by integers from 1 to N. No two places have the same number. The lines are bidi

2017-09-23 18:20:23 234

原创 UVA 10077 The Stern-Brocot Number System

题意: 题目:给你一颗分数组成的二叉树,初始值是1/1,两边的边界分别是0/1与1/0,然后递归建立子树节点,每个子树的节点值为两边的边界值的分子之和比上分母之和,然后将新的值也加入边界值。用二分搜索法来写#include <iostream>using namespace std;void find(int lx,int ly,int rx,int ry,int X,int Y){

2017-09-20 19:12:57 233

原创 HDU 4287 Intelligent IME

Problem Description   We all use cell phone today. And we must be familiar with the intelligent English input method on the cell phone. To be specific, the number buttons may correspond to some Englis

2017-09-16 21:50:38 299

空空如也

空空如也

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

TA关注的人

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