自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 B - exgcd

给出2个数M和N(M < N),且M与N互质,找出一个数K满足0 < K < N且K * M % N = 1,如果有多个满足条件的,输出最小的。Input输入2个数M, N中间用空格分隔(1 <= M < N <= 10^9)Output输出一个数K,满足0 < K < N且K * M % N = 1,如果有多个满足条件的,输出最小的...

2018-07-26 19:52:12 139 1

原创 A - 费马小定理

求:3^0 + 3^1 +...+ 3^(N) mod 1000000007Input输入一个数N(0 <= N <= 10^9)Output输出:计算结果Sample Input3Sample Output40#include <iostream>#include <cstdio>#include <cstd...

2018-07-26 19:51:39 165 1

原创 E - Vanya and Brackets CodeForces - 552E

Vanya is doing his maths homework. He has an expression of form , where x1, x2, ..., xn are digits from 1 to 9, and sign  represents either a plus '+' or the multiplication sign '*'. Vanya needs to ad...

2018-07-26 11:26:47 161 1

原创 I - Moon Game

Fat brother and Maze are playing a kind of special (hentai) game in the clearly blue sky which we can just consider as a kind of two-dimensional plane. Then Fat brother starts to draw N starts in the ...

2018-07-25 20:44:02 539

原创 111

#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn = 5e4 + 10;const int INF = (1 << 30);int t, n, m, x, y, z, ans, sum;int a[maxn], ha[maxn], vis[maxn],...

2018-07-24 11:34:38 108

原创 数据结构实验之图论十一:AOE网上的关键路径

Problem Description    一个无环的有向图称为无环图(Directed Acyclic Graph),简称DAG图。    AOE(Activity On Edge)网:顾名思义,用边表示活动的网,当然它也是DAG。与AOV不同,活动都表示在了边上,如下图所示:                                         如上所示,共有11项活动(...

2018-07-24 10:33:45 776

原创 N - Find a way HDU - 2612

Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki. Yifenfei’s home is at the ...

2018-06-08 19:41:43 285

原创 L - Oil Deposits HDU - 1241

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

2018-06-06 19:21:20 79

原创 I - Fire Game FZU - 2150

Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid of this board is consisting of grass or just empty and then they star...

2018-05-31 20:33:05 616

原创 H - Pots POJ - 3414

You are given two pots, having the volume of A and B liters respectively. The following operations can be performed: FILL(i)        fill the pot i (1 ≤ i ≤ 2) from the tap;DROP(i)  ...

2018-05-30 20:31:24 166

原创 G - Shuffle'm Up POJ - 3087

A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containin...

2018-05-30 19:39:03 134

原创 F - Prime Path POJ - 3126

The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. — It is a matter...

2018-05-29 19:48:50 132

原创 E - Find The Multiple POJ - 1426

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

2018-05-27 19:45:31 241

原创 D - Fliptile

Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in which they manipulate an M × N grid (1 ≤ M ≤ 1...

2018-05-27 19:29:24 105

原创 C - Catch That Cow POJ - 3278

Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (...

2018-05-26 15:53:06 177

原创 B - Dungeon Master POJ - 2251

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

2018-05-26 15:31:17 120

原创 A - 棋盘问题 POJ - 1321

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

2018-05-26 14:38:23 117

原创 二分查找

int BinarySearch(int a[], int l, int r, int key) { if(l > r) { return -1; } int mid = (l + r) >> 1; if(key == a[mid]) { return mid; } else if(key < a[mi...

2018-05-21 19:08:33 83

原创 高精度运算

#include <bits/stdc++.h>using namespace std;typedef long long ll;string add(string s, string s2) { string maxstr, minstr; if(s.length() > s2.length()) { maxstr = s; ...

2018-05-19 20:48:32 115

原创 最短路-SPFA

#include <bits/stdc++.h>using namespace std;typedef long long ll;void SPFA(int s) { for(int i = 0; i <= n; i++) { dis[i] = (1 << 30); } dis[s] = 0; vis[x] =...

2018-05-19 19:10:40 104

原创 最小生成树-Prim

#include <bits/stdc++.h>#define INF (1 << 30)using namespace std;int t, n, m, x, y, sum, cnt, t1, t2, t3, flag;int mp[10005][10005], vis[10005], dis[10005];void Prim() { for(int ...

2018-05-19 15:15:26 86

原创 最小生成树-Kruskal

#include <bits/stdc++.h>using namespace std;const int maxn = 1e6 + 10;char s[maxn], s2[maxn];int t, n, m, x, cnt, sum;int f[555];typedef long long ll;typedef long double ld;typedef stru...

2018-05-17 19:59:39 106

原创 KMP

#include <bits/stdc++.h>using namespace std;const int maxn = 1e6 + 5;char s[maxn], s2[maxn];int book[maxn];void getnext(char s2[]) { int i = 0, j = -1; book[0] = -1; while(s2[i...

2018-05-16 20:08:41 80

原创 第九届山东省省赛总结

山东省赛总结选拔时,虽然没进入正式队伍。还是抱着学习的态度去参加。热身赛的时候,没有午睡 状态不太好,敲代码是出现了许多小错误,导致后面用了大量时间来找错误。在热身赛中,我们队只做出了一个题,还是个水题。全是自己的原因,对字符串操作有瑕疵,在处理字符串的时候没有加反斜杠0,在我手中耽误了半个小时。然后节奏乱了,我就把位置让给了钟鑫豪。改了一分钟就改好了,然后就交了。后面开了两个题,我感觉我开的那个...

2018-05-16 19:10:30 200

原创 最大连续和

1、暴力求解 O(n3) int maxsum = a[1]; for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { int sum = 0; for(int k = i; k <= j; k++) { s...

2018-04-23 19:49:31 548

原创 常用小技巧

c++头文件#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <algorithm>#include <cstring>#include <queue>#include <stac

2018-04-15 15:57:58 551

原创 逆元

小费马定理求逆元(复杂度O(logn))ll FastPower(ll n, ll k) { ll ans = 1; k %= mod; while(n) { if(n % 2) { // n & 1 ans = (ans * k) % mod; } n >>= 1; ...

2018-04-13 19:35:26 108

原创 最短路--Dijkstra

#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <algorithm>#include <cstring>#include <queue>#include <stack&

2018-04-13 16:59:55 91

原创 最短路--Floyd

#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <algorithm>#include <cstring>#include <queue>#include <stack&

2018-04-13 16:47:25 75

原创 快速幂

#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <algorithm>#include <cstring>#include <queue>#include <stack&

2018-04-13 16:41:35 91

原创 F - 敌兵布阵

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

2018-04-08 20:43:36 134

原创 A - How to Type

Pirates have finished developing the typing software. He called Cathy to test his typing software. She is good at thinking. After testing for several days, she finds that if she types a string by so...

2018-04-08 20:38:53 119

原创 GPLT-总结

比赛总结 2018-03-31 GPLT(青岛站)软件1701郑康 2018-04-02(16:50)这是我第一次去校外参加比赛,虽然上学期就进入了504,但在里面一直处于划水的位置。有幸能够进入四队,虽然比赛只取前三队的成绩。海星学长多次提起如果可以超过三队,我们的成绩就会代替他们。抱着这种不切实际的幻想(赛后确实如此),尽可能多的做以往的天梯赛题,参加每晚的备战测试。印象最深刻的就是赛前一天晚...

2018-04-02 17:13:05 591

原创 大家快来A水题

Problem Description海上有N(1个岛,编号从1到N,同一部落的岛屿之间有直接或间接的路相连,不同部落之间无路可通。现在给出M(1条路。问这片海域上共有多少部落。Input 多组输入。每组第一行输入N,M。接下来M行每行,每行两个整数u,v代表岛u与v之间有一条路。Output 每组数据输出一个整数,代表部落数。 Example Input3

2018-02-01 20:21:25 143

原创 数据结构实验之图论九:最小生成树

Problem Description 有n个城市,其中有些城市之间可以修建公路,修建不同的公路费用是不同的。现在我们想知道,最少花多少钱修公路可以将所有的城市连在一起,使在任意一城市出发,可以到达其他任意的城市。 Input 输入包含多组数据,格式如下。第一行包括两个整数n m,代表城市个数和可以修建的公路个数。(n 剩下m行每行3个正整数a b c,代表城市

2018-02-01 20:20:29 225

原创 数据结构实验:连通分量个数

Problem Description 在无向图中,如果从顶点vi到顶点vj有路径,则称vi和vj连通。如果图中任意两个顶点之间都连通,则称该图为连通图,否则,称该图为非连通图,则其中的极大连通子图称为连通分量,这里所谓的极大是指子图中包含的顶点个数极大。例如:一个无向图有5个顶点,1-3-5是连通的,2是连通的,4是连通的,则这个无向图有3个连通分量。 Input 第

2018-02-01 20:19:33 133

原创 小鑫的城堡

Problem Description从前有一个国王,他叫小鑫。有一天,他想建一座城堡,于是,设计师给他设计了好多简易图纸,主要是房间的连通的图纸。小鑫希望任意两个房间有且仅有一条路径可以相通。小鑫现在把设计图给你,让你帮忙判断设计图是否符合他的想法。比如下面的例子,第一个是符合条件的,但是,第二个不符合,因为从5到4有两条路径(5-3-4和5-6-4)。Input多组输入,每

2018-02-01 20:18:41 104

原创 电影节

Problem Description某届电影节评选电影,共有两部电影进入最后评选环节,有n名观众,每个人有一次投票的机会,每个人都按照规则投给其中一部电影。为了了解情况,记者随机询问了一些人,一共询问了m次,特别神奇的是,记者每次都询问两个人,而且这两个人都把票投给了同一部电影,观众编号为1~n。Input多组输入,每组第一行是两个整数n,m (2 <= n <=100000,0 <

2018-02-01 20:17:37 107

转载 (转载)幷查集

http://blog.csdn.net/niushuai666/article/details/6662911

2018-02-01 20:03:04 115

原创 人活着系列之寻找最完美的人生

Problem Description也许,人活着就是要尝试人世间的酸甜苦辣,喜怒哀乐,经历从婴儿到老人的一个过程吧!能看,能想,能爱,能恨,这就是活人与死人的区别。不要想着死后会怎样,谁也不知道。所以要好好的活着,宽待自己,好好珍惜身边的人!现在,上帝之手宽恕与你。把你人生中所要经历的所有的酸甜苦辣全部摆在你的面前。你一生需要经历n种事情。每种事情都有一个权值x。上帝给了你n-1个时

2018-02-01 15:26:30 145

空空如也

空空如也

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

TA关注的人

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