自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Codeforces Round #529 (Div. 3)

https://codeforces.com/contest/1095/problem/A题意:给定一个长度为n的加密过的字符串,找到他的原来的序列,加密的过程就是第一个字符输出一个,第二个字符输出两个,第三个输出三个,依次;思路:设置一个标志位每次递增,输出相应的字符。#include<bits/stdc++.h>int main(){ int n; ...

2019-02-16 15:31:54 254 1

原创 Codeforces Round #536 (Div. 2)

https://codeforces.com/contest/1106/problem/A题意:给定一个n*n的字符串,看能由x组成几个 “X”。思路:直接遍历一遍,然后将能够组成的X的找出来#include<bits/stdc++.h>#define ll long longusing namespace std;int main(){ char ch...

2019-02-16 13:24:17 260

原创 Codeforces Round #531 (Div. 3)

https://codeforces.com/contest/1102/problem/A题意:给定一个数n,将1-n分成两组,使得两组数的差值最小,输出最小差值。思路:根据推理发现,随着n的增大,是有规律出现的,跟4的倍数有关系。#include<bits/stdc++.h>#include<iostream>using namespace std;#...

2019-02-02 21:22:28 230

原创 Codeforces Round #535 (Div. 3)

https://codeforces.com/contest/1108/problem/A这个题的意思就是给你两个区间,在第一个区间中找一个点a,使l1<=a<=r1,在第二个区间中找一个点b,使l2<=b<=r2。很简单,直接把两个区间的左端点输出就行了,如果两个区间的左端点相同,则把第二个区间的右端点输出。#include<bits/stdc++.h...

2019-01-29 21:35:32 253

原创 小乐乐下象棋

链接:https://ac.nowcoder.com/acm/contest/301/F题目描述小乐乐一天天就知道玩,这一天又想玩象棋。我们都知道马走日。现在给定一个棋盘,大小是n*m,把棋盘放在第一象限,棋盘的左下角是(0,0),右上角是(n - 1, m - 1);小乐乐想知道,一个马从左下角(0, 0)开始,走了k步之后,刚好走到右上角(n - 1, m - 1)的方案数。...

2018-12-05 21:20:59 247

原创 小乐乐搭积木

链接:https://ac.nowcoder.com/acm/contest/301/B题目:小乐乐想要给自己搭建一个积木城堡。积木城堡我们假设为n*m的平面矩形。小乐乐现在手里有1*2,2*1两种地砖。小乐乐想知道自己有多少种组合方案。 输入描述:第一行输入整数n,m。(1<=n,m<=10)输出描述:输出组合方案数。示例1输入2 3...

2018-12-05 20:51:37 439

原创 BSGS(拔山盖世算法),北上广深算法

1.引入BSGS算法又名拔山盖世算法,也叫北上广深算法,也叫大步小步算法,总之就是名字很多了,但是实际上他就是一个解决同余方程 给定a,b,p,求最小的非负整数x,满足  ax ≡ b(mod p)。2.过程先令 x = i*m-j,其中 m=ceil(sqrt(p)),ceil是向上取整。这样原式就变为     ai*m-j = b (mod p),移项就变成了       ...

2018-08-13 20:39:24 1944

原创 莫队! 莫队!

1.传说中能够解决一切区间问题的算法,其实就是一种优化了的暴力解法。当知道一个区间的[L,R]的范围,你就可以求出[L-1,R],[L,R-1],[L-1,R-1],区间的范围,莫队算法的实质是通过将询问排序,每个询问均由前一个询问(排序后的)转移得来,通过一定的排序优化时间复杂度。往往可以有O(N,√N)的效果,显然对于两次询问L,R和L′,R′,知道了L,R的答案,就可以暴力计算|L−L′...

2018-08-13 11:03:04 466

原创 异或序列

题目描述已知一个长度为n的整数数列a1,a2,…,an,给定查询参数l、r,问在al,al+1,…,ar区间内,有多少子序列满足异或和等于k。也就是说,对于所有的x,y(l≤x≤y≤r),满足ax⊕ax+1⊕⋯⊕ay=k的x,y有多少组。 输入输入第一行为3个整数n,m,k。第二行为空格分开的n个整数,即a1,a2,…,an。接下来m行,每行两个整数lj,rj,代表一次查询。 ...

2018-08-09 10:34:47 630

原创 HDU6000 洗衣服

洗衣服时间限制: 2 Sec  内存限制: 128 MB提交: 53  解决: 15[提交] [状态] [讨论版] [命题人:admin]题目描述你现在要洗L件衣服。你有n台洗衣机和m台烘干机。由于你的机器非常的小,因此你每次只能洗涤(烘干)一件衣服。第i台洗衣机洗一件衣服需要wi分钟,第i台烘干机烘干一件衣服需要di分钟。请问把所有衣服洗干净并烘干,最少需要多少时间?假设衣服在...

2018-08-08 19:39:27 551 1

原创 C++ pair用法

pair相当于是包含有两个变量的struct,同样类型的pair变量可以直接赋值,这里比struct要方便,写的时候也很简单,确实很好用,而且first和second可以直接调出里面的两个元素。1.定义。创建一个新的pair对象:pair<T1,T2> p1; 创建好的p1他的两个元素分别为T1,T2类型的。并且p1.first代表p1中的第一个元素,p1.second代表第二...

2018-08-08 16:40:21 1101 1

原创 拓扑排序

1、 拓扑排序解释  我们起床穿裤子和鞋子时,相信大部分人的顺序是这样的,先穿上内裤,然后再穿上裤子,再穿上袜子,然后才是鞋子。  那么,我们把这些步骤分解:(1)穿内裤(2)穿裤子(3)穿袜子(4)穿鞋子我们把这四个步骤,按照上述的顺序 给排一下,这就是所谓的拓扑排序。当然这个排序的顺序是唯一的,如果你先进行(2)然后(1)(3)(4),哦,不,你不是超人,请不要这样...

2018-08-05 20:53:44 1868

转载 Milking Order

题目描述Farmer John's N cows (1≤N≤105), numbered 1…N as always, happen to have too much time on their hooves. As a result, they have worked out a complex social hierarchy related to the order in which F...

2018-08-04 19:57:27 479

原创 Small Multiple

Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K.Constraints2≤K≤105K is an integer.  输入Input is given from Standard Input in the following fo...

2018-08-04 15:56:16 407

原创 Built?

There are N towns on a plane. The i-th town is located at the coordinates (xi,yi). There may be more than one town at the same coordinates.You can build a road between two towns at coordinates (a,b) ...

2018-08-04 11:01:52 311

原创 Fennec VS. Snuke

题目描述Fennec and Snuke are playing a board game.On the board, there are N cells numbered 1 through N, and N−1 roads, each connecting two cells. Cell ai is adjacent to Cell bi through the i-th road. E...

2018-08-03 20:47:17 276

转载 链式前向星

之前我们介绍过图的邻接矩阵存储法,它的空间和时间复杂度都是N2,现在我来介绍另外一种存储图的方法:邻接表,这样空间和时间复杂度就都是M。对于稀疏图来说,M要远远小于N2。先上数据,如下。 4 51 4 94 3 81 2 52 4 61 3 7         第一行两个整数n m。n表示顶点个数(顶点编号为1~n),m表示边的条数。接下来m行表示,每行有3个数x ...

2018-08-02 20:50:05 504

原创 问题 I: Sandglass

 题目描述We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contain some amount of sand. When we put the sandglass, either bulb A or B lies on top of the other and becomes the...

2018-07-31 20:59:31 259

原创 cpu Restoring Road Network

In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are known about the road network:People traveled between c...

2018-07-31 20:28:02 325

原创 LDU 个人训练赛二 I Interesting Integers

Undoubtedly you know of the Fibonacci numbers. Starting with F1 = 1 and F2 = 1, every next number is the sum of the two previous ones. This results in the sequence 1, 1, 2, 3, 5, 8, 13, . . .. Now let...

2018-07-30 17:05:20 315

原创 cpu个人训练四 K 打地鼠游戏

题目描述伟大的2320学长特别喜欢打地鼠游戏,这个游戏开始后,会在地板上冒出一些地鼠来,你可以用榔头去敲击这些地鼠,每个地鼠被敲击后,将会增加相应的游戏分值。可是,所有地鼠只会在地上出现一段时间(而且消失后再也不会出现),每个地鼠都在0时刻冒出,但停留的时间可能是不同的,而且每个地鼠被敲击后增加的游戏分值也可能是不同。最近2320学长经常玩这个游戏,以至于敲击每个地鼠只要1秒。他在想如何敲击...

2018-07-29 20:07:31 481

原创 LDU 2018宁夏邀请赛 D. Take Your Seat

朵哈要坐飞机去旅游,出发的时候有包括朵哈在内一共有 n 个人要上飞机。这班飞机有 n 个座位, 第 i 个人的座位号是 i,朵哈的座位号就是 1。 现在 n 个人按照座位号是 1 到 n 的顺序上飞机。但朵哈忘了自己的座位,于是她就等概率随机选一 个位置坐下了。而其余人都记得自己的座位。如果他们中的一个人上飞机后发现自己的位子被占了,则会 在剩下的位置中等概率随机选一个坐下;如果没被占,则会直接坐...

2018-07-29 16:13:25 727

原创 LDU 个人训练三 宁夏邀请赛 A Maximum Element In A Stack

Problem A. Maximum Element In A Stack Time limit: 10 seconds As an ACM-ICPC newbie, Aishah is learning data structures in computer science. She has already known that a stack, as a data structure, c...

2018-07-28 23:14:37 381

原创 LDU个人训练三 2018宁夏邀请赛 H Fight Against Monsters

Problem H.Fight Against Monsters Time limit: 10 seconds It is my great honour to introduce myself to you here. My name is Aloysius Benjy Cobweb Dartagnan Egbert Felix Gaspar Humbert Ignatius Jayden ...

2018-07-28 23:03:48 745

原创 Column Addition

A multi-digit column addition is a formula on adding two integers written like this:A multi-digit column addition is written on the blackboard, but the sum is not necessarily correct. We can erase any...

2018-04-23 21:45:48 258

原创 Boxes

题目描述There are N boxes arranged in a circle. The i-th box contains Ai stones.Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:Se...

2018-04-23 16:59:21 441

原创 树状数组

 树状数组的用途 树状数组可以解决数量级较大的区间求和问题,区间求最值问题,区间修改、查询问题以及 求逆序对等应用。树状数组的时间复杂度 O(log2n),正常情况下远远快于线性时间 O(n)。  树状数组的原理 图 2 中,a 数组就是需要维护求区间和的数组,其实a 数组在求区间和的时候并没有太大的 意义,只是求区间最值的时候会有用到。我们先来关注一下储存和的 c 数组。 C8=...

2018-03-03 09:53:21 257 1

原创 矩阵快速幂

1.矩阵的乘法。   int a[10][20],b[20][30];    int c[10][30];    int i,j,k;    memset(c,0,sizeof(c));    for(i=0;i<10;i++)    {        for(j=0;j<30;j++)        {            for(k=0;k<20;...

2018-02-01 10:33:27 225

原创 博弈

首先,先拿一个例题介绍一下巴什博弈。(Bash Game)最重要的公式n%(m+1)==0先手必败否则后手必败 http://acm.hdu.edu.cn/showproblem.php?pid=1846 像这样2人采用最优策略取石子的问题就是典型的巴什博弈的思想 假设一开始有n个石子那么n一定可以写成n=(m+1)*r+s的形式,既然这样的话,假如A先取,那么一开始A...

2018-01-30 20:10:21 484

原创 计算几何

计算几何基础向量叉乘A (x1,y1)  B(x2,y2)  A×B= x1y2-x2y1叉乘判断向量位置,P×Q 在 Q 左侧,P×Q > 0  P在 Q 右侧,P×Q > 0  P与 Q 共线,向量点乘A (x1,y1)  B(x2,y2)  A·B=x1x2+y1y2    a

2018-01-30 20:05:57 473

原创 扩展欧几里德一系列算法

一、欧几里德算法又称辗转相除法,用于计算两个正整  a,b的最大公约数。定理:gcd(a,b) = gcd(b,a%b) 。代码实现如下:#include<stdio.h>#define ll long longll gcd(ll m,ll n){    if(n==0)        return m;    return gcd(n,m%n);}int ...

2018-01-29 17:10:54 682

原创 素数筛选法

1.普通的素数筛选法(最先接触到的):#include<stdio.h>#include<stdlib.h>#include<iostream>#include<string>#include<cstdio>#include<cstring>#include<vector>#include&am

2018-01-27 21:04:48 366

原创 最小生成树kruskal算法 克鲁斯卡尔算法

1、Kruskal算法描述      Kruskal算法是基于贪心的思想得到的。首先我们把所有的边按照权值先从小到大排列,接着按照顺序选取每条边,如果这条边的两个端点不属于同一集合,那么就将它们合并,直到所有的点都属于同一个集合为止。至于怎么合并到一个集合,那么这里我们就可以用到一个工具——-并查集。换而言之,Kruskal算法就是基于并查集的贪心算法。2、Kruskal算法实现过程此...

2018-01-27 11:18:41 472

原创 Floyd 最短路

#include<stdio.h>#include<stdlib.h>#include<iostream>#include<string>#include<cstdio>#include<cstring>#include<vector>#include<math.h>#

2018-01-25 21:03:21 321

原创 迪杰斯特拉算法 最短路

#include<stdio.h>#include<string.h>#include<algorithm>int m,n;int from[999][999];int ans;int vis[999],dis[999];void prim(){    int i,j,k;    int idex;    ans=0;idex=0;  ...

2018-01-25 20:51:12 358

原创 Wireless Network 并查集

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-01-24 20:34:58 196

原创 并查集

并查集最主要的是查找元素是否在同一棵树上,或者看看所给的元素分布在几棵树上。最主要的是两个函数一个是寻找根节点的函数,另一个则是压缩路径的函数,根节点有一定的特性,根节点的数等于它本身。附上两个最基本的函数:1.寻找根节点的函数;int findd(int x){    if(a[x]==x)        return x;    else        retu...

2018-01-24 20:13:54 161

原创 快速幂

Given a positive integer N, you should output the most right digit of N^N. InputThe input contains several test cases. The first line of the input is a single integer T which is the number of te...

2018-01-17 20:46:45 189

原创 Registration system

A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You'r...

2018-01-17 20:45:39 704

原创 Before an Exam

Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, ...

2018-01-17 20:33:04 372

空空如也

空空如也

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

TA关注的人

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