自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 取石子游戏

有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。 Input输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,000,000。Output输出对应也有若干行,每行包含一个数字1或0.

2020-05-23 19:48:24 291

原创 约瑟夫环问题

约瑟夫环问题 N个人坐成一个圆环(编号为1 - N),从第1个人开始报数,数到K的人出列,后面的人重新从1开始报数。问最后剩下的人的编号。例如:N = 3,K = 2。2号先出列,然后是1号,最后剩下的是3号。Input2个数N和K,表示N个人,数到K出列。(2 <= N, K <= 10^6)Output最后剩下的人的编号Sample Input3 2Sample Output3代码:#include"stdio.h"int main(){ int n,k,

2020-05-10 16:07:46 521

原创 Polycarp's Pockets

Polycarp has nn coins, the value of the ii-th coin is aiai. Polycarp wants to distribute all the coins between his pockets, but he cannot put two coins with the same value into the same pocket.For ex...

2019-10-09 13:42:09 150

原创 Polo the Penguin and Strings

Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions:The string consists of n lowercase English le...

2019-09-08 22:26:50 132

原创 Kitahara Haruki's Gift

Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki ...

2019-09-07 21:22:32 151

原创 Haiku

Haiku is a genre of Japanese traditional poetry.A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactl...

2019-09-06 21:24:11 293

原创 Testing Pants for Sadness

The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called “Testing Pants for Sadness”.The test consi...

2019-09-05 21:12:13 220

原创 Hexadecimal's theorem

Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci n...

2019-09-04 21:37:07 234

原创 Han Solo and Lazer Gun

There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.Han Solo has t...

2019-09-03 21:33:32 102

原创 Panoramix's Prediction

A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.The next prime number after x is the smallest prime num...

2019-09-02 22:21:46 115

原创 Valuable Resources

Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems.Let’s suppose that your task is to build a s...

2019-09-01 22:08:31 355

原创 Sereja and Coat Rack

Sereja owns a restaurant for n people. The restaurant hall has a coat rack with n hooks. Each restaurant visitor can use a hook to hang his clothes on it. Using the i-th hook costs ai rubles. Only one...

2019-08-31 22:31:19 122

原创 迪杰斯特拉算法(Dijkstra)求最短路径

模板如下:#include"stdio.h"#include"string.h"#define N 3000#define INF 0x3f3f3f3fint e[N][N];int dist[N];//起始点到各顶点i的距离int visited[N];int pre[N];//pre[i]=j,从j-->i 用于记录路径,如果题目要求输出int n, m;//顶点数,...

2019-08-30 21:38:45 425

原创 Big Segment

A coordinate line has n segments, the i-th segment starts at the position li and ends at the position ri. We will denote such a segment as [li, ri].You have suggested that one of the defined segments...

2019-08-29 22:04:20 162

原创 Sinking Ship

The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let’s label them all from left to right with posi...

2019-08-28 21:03:45 134

原创 Shooshuns and Sequence

One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps:Find the number that goes k-th in the c...

2019-08-27 20:43:35 83

原创 Two Bags of Potatoes

Valera had two bags of potatoes, the first of these bags contains x (x ≥ 1) potatoes, and the second — y (y ≥ 1) potatoes. Valera — very scattered boy, so the first bag of potatoes (it contains x pota...

2019-08-26 19:49:40 313

原创 Collecting Beats is Fun

Cucumber boy is fan of Kyubeat, a famous music game.Kyubeat has 16 panels for playing arranged in 4 × 4 table. When a panel lights up, he has to press that panel.Each panel has a timing to press (th...

2019-08-25 20:40:42 109

原创 Vasya and Digital Root

Vasya has recently found out what a digital root of a number is and he decided to share his knowledge with you.Let’s assume that S(n) is the sum of digits of number n, for example, S(4098) = 4 + 0 + ...

2019-08-24 20:51:48 153

原创 Levko and Table

Levko loves tables that consist of n rows and n columns very much. He especially loves beautiful tables. A table is beautiful to Levko if the sum of elements in each row and column of the table equals...

2019-08-23 19:36:11 126

原创 Squats

Pasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and each hamster either sat down or stood up.For another exercise, Pasha need...

2019-08-22 17:22:27 290

原创 Blackjack

One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found ...

2019-08-21 17:29:25 220

原创 Currency Exchange

Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can...

2019-08-20 21:31:38 158

原创 弗洛伊德(Floyd)算法(求最短路径)

之前已经发过两个利用弗洛伊德算法来求最短路径的题了,但是一直说有模板,却没有明确说过,今天我就要告诉大家到底哪一部分才是模板 ,下面请看:代码如下:#include"stdio.h" #include"string.h" #include"string" #include"iostream" #include"stack"#include"queue" #include"...

2019-08-20 21:07:20 609

原创 畅通工程续

某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。 每组数据第一行包含两个正整数N和M(0<N<200,0<M&lt...

2019-08-19 19:14:36 468

原创 最短路

在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M<=10000),N表示成都的大街上有几个路口,标号为1的路口是商店所在地,标号为N的路口是赛场所在...

2019-08-18 21:12:57 65

原创 Frogger

湖中有n块石头,编号从1到n,有两只青蛙,Bob在1号石头上,Alice在2号石头上,Bob想去看望Alice,但由于水很脏,他想避免游泳,于是跳着去找她。但是Alice的石头超出了他的跳跃范围。因此,Bob使用其他石头作为中间站,通过一系列的小跳跃到达她。两块石头之间的青蛙距离被定义为两块石头之间所有可能路径上的最小必要跳跃距离,某条路径的必要跳跃距离即这条路径中单次跳跃的最远跳跃距离。你的工作...

2019-08-17 21:25:54 141

原创 Postcards and Photos

Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter’s picture. Polycarpus does it like that: he goes from the...

2019-08-15 20:11:25 410

原创 Little Elephant and Rozdil

The Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. “Rozdil”).However, Rozdil is dangerous to settle, so the Little Elephant wants to go to some other town. The Little...

2019-08-14 21:23:16 146

原创 Constructing Roads

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 connected, if and only if t...

2019-08-13 21:01:00 113

原创 畅通工程

某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;随后的M行对应M条道路,每行给出一对正...

2019-08-12 21:30:57 104

原创 Prime Ring Problem

颜良某天ak太多了心烦,想带领小伙伴们做游戏 。游戏内容如下:当颜良喊出一个数字n时,便有n个小伙伴,身上带着1到n的数字,手牵手拉成一个环。当环里的每个人相邻两人身上数字之和都为素数时,便找到了一个环。当找出所有的环时,游戏便结束。Note: 每个环的第一个数字必须是1Inputn (0 < n < 20).Output输出格式如下方输出样例所示。每行一串数字表示一种...

2019-08-11 22:18:49 154

原创 深搜

有一个长方形的房间,覆盖了正方形的磁砖。每块磁砖的颜色,要么是红色,要么是黑色。一名男子站在一块黑色的磁砖上。他可以从一块磁砖移至相邻四块磁砖中的某一块。但是,他不允许在红色磁砖上移动,他只允许在黑色磁砖上移动。编写一个程序,使得他允许重复上述的移动,判断他所能到达的黑色磁砖的数量。输入输入由多个数据集组成。数据集的起始行包含了两个正整数 W 和 H;W 和 H 分别是 x- 和 y- 方向的...

2019-08-10 20:58:22 91

原创 Dungeon Master

你被困在一个三维的空间中,现在要寻找最短路径逃生!空间由立方体单位构成,你每次向上下前后左右移动一个单位需要一分钟,你不能对角线移动并且四周封闭,是否存在逃出生天的可能性?如果存在,则需要多少时间?Input输入第一行是一个数表示空间的数量。每个空间的描述的第一行为L,R和C(皆不超过30)。L表示空间的高度,R和C分别表示每层空间的行与列的大小。随后L层地牢,每层R行,每行C个字符。每个字符...

2019-08-09 21:14:12 254

原创 Catch That Cow

农夫知道一头牛的位置,想要抓住它。农夫和牛都于数轴上 ,农夫起始位于点 N(0<=N<=100000) ,牛位于点 K(0<=K<=100000) 。农夫有两种移动方式: 1、从 X移动到 X-1或X+1 ,每次移动花费一分钟 2、从 X移动到 2*X ,每次移动花费一分钟 假设牛没有意识到农夫的行动,站在原地不动。最少要花多少时间才能抓住牛?Input一行: 以空格分...

2019-08-08 21:59:40 173

原创 铁轨(Rails)

某城市有一个火车站,铁轨铺设如下图所示。有n节车厢从A方向驶入车站,按进站顺序编号为1~n。你的任务是判断是否能让它们按照某种特定的顺序进入B方向的铁轨并驶出车站。例如,出栈顺序是(5 4 1 2 3)是不可能的,但(5 4 3 2 1)是可能的。为了重组车厢,你可以借助中转站C。这是一个可以停放任意多节车厢的车站,但由于末端封顶,驶入C的车厢必须按照相反的顺序驶出C。对于每个车厢,一旦从A移入...

2019-08-07 21:07:34 412

NCREOneProject.exe

NCREOneProject.exe

2022-11-07

空空如也

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

TA关注的人

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