自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 二分通用模板

二分通用模板

2023-04-16 12:44:51 90

原创 一文搞定常见的链表问题

一文搞定常见的链表问题

2023-03-02 20:07:46 114 1

原创 Codeforces Round #563 (Div. 2) D、Ehab and the Expected XOR Problem

题解:赛后看题解补做的;假设c数组为所求数组,a数组为其前缀异或和,即 ai=c1^c2^...^ci;则c中任意连续子段 [cl, cl+1, ..., cr] 异或和cl^cl-1^...^cr = al-1^ar;故只需求出满足一下条件的a数组:1、ai^aj != 0;2、ai^aj != x;然后由a数组求出c数组即可;(可利用 a^b=c; ...

2019-06-04 13:18:39 216

原创 scanf、getchar函数 返回值测试

1、scanf() 返回值为 int 型,成功读入一个数, 返回1,成功读入两个数,返回2,以此类推;读入结束时返回 EOF, 即 -1; 2、getchar() 返回值为 int 型,为用户输入的ASCII码或EOF。 ...

2018-12-01 21:02:53 316

原创 纵横字谜的答案 UVA - 232

题就不复述了;题解:这道题挺好写的,暴力就行了,输出输出比较个性,输出的序号要占三个格,忽视这个为wa到哭的;#include <iostream>#include <cstring>#include <cstdio>using namespace std;char a[15][15];int b[15][15];int main(){...

2018-09-22 20:58:12 338

原创 谜题 UVA - 227

题解:挺水的一道题,不过有两个坑;一是输入的数组 空格 如果在行末的时候,是不输出的,如样例2;二是输入的指令可能分多行输入,如样例2;#include <iostream>#include <cstdio>#include <cstring>char c, s[10][10];char cmd[1111];int mai...

2018-09-19 23:49:37 286

原创 isalpha、isupper、islower 函数

一、isalpha原型:int isalpha(int ch)头文件:#include <cctype>(C语言使用<ctype.h>)功能:判断字符ch是否为英文字母,当ch为英文字母a-z或A-Z时,返回非零值(不一定是1),否则返回零。在标准c中相当于使用“ isupper(ch) || islower(ch)”做测试。 二、isupper...

2018-09-18 22:20:27 2275

原创 getchar()函数测试

一、getchar有一个int型的返回值.当程序调用getchar时.程序就等着用户按键.用户输入的字符被存放在键盘缓冲区中.直到用户按回车为止(回车字符也放在缓冲区中).当用户键入回车之后,getchar才开始从stdin流中每次读入一个字符.getchar函数的返回值是用户输入的第一个字符的ASCII码,如出错返回-1,且将用户输入的字符回显到屏幕.如用户在按回车之前输入了不止...

2018-09-18 21:32:21 306

原创 strlen()函数、strcmp()函数 测试

1. strlen()函数测试——strlen()函数用来计算  字符串的长度;其原型为:unsigned int strlen (char *s);  s为指定的字符串测试后可知 strlen()函数遇到 '\0' 时返回结果;如--- s[5]="abcd";                      strlen(s)=4;--- s[5]="abcd"; s[4]=...

2018-09-18 21:10:38 553

原创 棋盘问题

在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n...

2018-09-18 00:27:40 125

原创 High Score

 题解:平方增长更快些,所以大数据的情况下更适合全部累加到一个数上,小数据暴力枚举就行了;#include<iostream>#include<algorithm>using namespace std;typedef long long LL;const int maxn=1000;int T;LL a, b, c, d;LL ans;L...

2018-08-27 17:47:45 1012

原创 Dunglish

题解:这道题用 map 做的话是很简单的,构建两个map<string, int >,一个用来储存正确的翻译个数,一个用来储存储存错误的翻译个数,总的和正确的可以轻松求出,错误的就是总的减去正确的。如果总方案数为1,正确的也为1, 那么就输出正确的翻译和 correct;否则输出错误的翻译和 incorrect; #include<cstdio&gt...

2018-08-27 17:17:18 199

原创 Boss Battle

题解:题目描述:有环形的n根柱子,只有一根柱子后面有boss,每次向一根柱子投一个炸弹,炸弹波及范围为那根柱子和相邻的柱子,若boss在这三根柱子后面,则boss被炸死,若boss没有被炸死,则boss会选择原地不动或者走到相邻的柱子,问最坏情况下要用多少个炸弹。显然:当n≤3时,答案是1。但n>3时,观察可得答案是n−2。因为在每次扔完炸弹后,第二次扔在那个炸弹的顺时针...

2018-08-27 16:51:12 214

原创 Two strings

You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of st...

2018-08-24 18:34:34 564

原创 Minimal string

Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves:Extract the...

2018-08-24 16:29:01 210

原创 Jam's balance

Jim has a balance and N weights. (1≤N≤20)(1≤N≤20) The balance can only tell whether things on different side are the same weight. Weights can be put on left side or right side arbitrarily. Please t...

2018-08-22 12:13:30 311

原创 最短路

Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his cus...

2018-08-21 20:26:08 105

原创 最小生成树

The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has already constructed a numb...

2018-08-21 19:41:58 225

原创 最小生成树

Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course.Farmer John ordered a high spee...

2018-08-21 18:24:09 120

原创 最小生成树

The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly,...

2018-08-21 18:17:01 103

原创 最短路

BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research advi...

2018-08-21 17:39:45 91

原创 最短路

Stockbrokers are known to overreact to rumours. You have been contracted to develop a method of spreading disinformation amongst the stockbrokers to give your employer the tactical edge in the stock m...

2018-08-21 16:07:21 91

原创 线段树区间更改区间查询

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 ...

2018-08-21 13:44:10 111

原创 线段树

The inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj. For a given sequence of numbers a1, a2, ..., an, if we move the f...

2018-08-21 13:02:07 80

原创 线段树

For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things ...

2018-08-21 10:35:20 69

原创 树状数组

Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and ...

2018-08-19 21:27:45 97

原创 线段树

C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演习什么战术,所...

2018-08-19 20:06:43 83

原创 拓扑排序

有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。 Input输入有若干组,每组中的第一行为二个数N(1<=N<=500),M;其中N表...

2018-08-19 18:46:24 130

原创 拓扑排序

The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. They gather together in different groups, so that a Martian can have one parent ...

2018-08-19 18:03:30 100

原创 搜索剪枝

Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t = 4, n = 6, and the list is [4, 3, 2, 2, 1, 1], then there ar...

2018-08-19 15:15:05 322

原创 搜索剪枝

7月17日是Mr.W的生日,ACM-THU为此要制作一个体积为Nπ的M层生日蛋糕,每层都是一个圆柱体。 设从下往上数第i(1 <= i <= M)层蛋糕是半径为Ri, 高度为Hi的圆柱。当i < M时,要求Ri > Ri+1且Hi > Hi+1。 由于要在蛋糕上抹奶油,为尽可能节约经费,我们希望蛋糕外表面(最下一层的下底面除外)的面积Q最小。 令Q = Sπ ...

2018-08-18 17:51:03 104

原创 搜索剪枝

George 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 he had orig...

2018-08-18 15:36:06 169

原创 广搜

Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there...

2018-08-17 16:42:06 149

原创 二分或者hash

The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x C x D are such that a + b + c + d = 0 . In the followin...

2018-08-17 14:44:08 164

原创 单调队列

An array of size n ≤ 10 6 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each tim...

2018-08-16 21:12:31 80

原创 尺取法

Signals of most probably extra-terrestrial origin have been received and digitalized by The Aeronautic and Space Administration (that must be going through a defiant phase: "But I want to use feet, no...

2018-08-16 20:14:59 90

原创 Play on Words

Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very impo...

2018-08-16 16:12:04 100

原创 并查集

动物王国中有三类动物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。 此人对N个动物,用上述两种说法,一句接一句地说出K句话...

2018-08-12 20:14:07 75

原创 并查集

There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university beli...

2018-08-12 17:41:33 99

原创 并查集

An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n...

2018-08-12 16:22:00 133

空空如也

空空如也

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

TA关注的人

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