自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 GCD Game(尼姆博弈 处理质因子)

每个数相当于一堆石子,每个数的质因子个数为每堆石子的石子数代码:#include"stdio.h"#include"string.h"#include"algorithm"using namespace std;int vis[10000010],p[10000010],num[10000010];void init(){ int i,j,cnt=0; for(i=2;i<=10000010;i++) { if(!vis[i]) { p[cnt++]=i; .

2021-08-13 08:38:43 312

原创 中国剩余定理模板

已知,a,b,c两两互质,n%a=x,n%b=y,n%c=z。现在给你a,b,c,x,y,z,求最小的n。代码:#include"stdio.h"#include"string.h"int main(){ long long a,b,c,x,y,z,m1,m2,m3,m; scanf("%lld %lld %lld %lld %lld %lld",&a,&b,&c,&x,&y,&z);//a,b,c两两互质 m1=a*b; m2=a*c;

2021-06-16 21:23:49 118

原创 简单几何(叉积模板)

给你一个矩形的左下点和右上点的坐标,以及一条线段的两个端点的坐标,判断线段是否与矩形相交。相交输出T,否则输出F。输入:14 9 11 2 1 5 7 1输出:F思路:对矩形的四条边分别和线段进行叉积判断是否相交代码:#include"math.h"#include"stdio.h"#include"string.h"#include"algorithm"using namespace std;struct M{ double x,y;}a1,a2,b1,b2,b3,b

2021-05-17 19:29:02 176

原创 莫队算法模板

给你一个n,接下来给你n个数的数组,之后给你m,接下来有m个区间,让你求每个区间中每个数字数量的立方和。例:输入:81 1 3 1 3 1 3 341 83 85 65 5输出:1287221代码:#include"map"#include"math.h"#include"stdio.h"#include"string.h"#include"algorithm"using namespace std;int m,n,pos[100010],c[100010];

2021-05-14 21:48:10 89

原创 Drainage Ditches HDU - 1532(EK算法&Dinic算法 最大流模板)

Every time it rains on Farmer John’s fields, a pond forms over Bessie’s favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Farmer John has built a set of drainage ditches so that Be

2021-04-29 19:42:21 123

原创 魔法少女(简单动态规划)

前些时间虚渊玄的巨献小圆着实火了一把。 在黑长直(小炎)往上爬楼去对抗魔女之夜时,她遇到了一个问题想请你帮忙。 因为魔女之夜是悬浮在半空的,所以她必须要爬楼,而那座废墟一共有 nn 层,而且每层高度不同,这造成小炎爬每层的时间也不同。不过当然,小炎会时间魔法,可以瞬间飞过一层或者两层[即不耗时]。但每次瞬移的时候她都必须要至少往上再爬一层(在这个当儿补充魔力)才能再次使用瞬移。爬每单位高度需要消耗小炎 11 秒时间。 消灭魔女之夜是刻不容缓的,所以小炎想找你帮她找出一种最短时间方案能通往楼顶。输入格式第

2021-04-16 21:21:32 99

原创 2016-省赛-C语言大学B组题解

1.煤球数目有一堆煤球,堆成三角棱锥形。具体:第一层放1个,第二层3个(排列成三角形),第三层6个(排列成三角形),第四层10个(排列成三角形),…如果一共有100层,共有多少个煤球?* ** * * * ** * * * * * * * ** * * *171700代码:#include"stdio.h"int main(){ int i,s=0,sum=0; for(i=1;i<=100;i++) { s=s+i; sum

2021-03-25 22:00:36 547

原创 POJ 3273 Monthly Expense(二分)

Farmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exact amount of money (1 ≤ moneyi ≤ 10,000) that he will need to spend each day over the next N (1 ≤ N ≤ 1

2021-02-23 20:32:16 130

原创 POJ 3262 Protecting the Flowers(贪心)

Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his horror that the cluster of cows was in his garden eating his beautiful flowers. Wanting to minimize the subsequent damage, FJ

2021-02-20 20:17:57 333

原创 POJ 3250 Bad Hair Day(单调栈)

Some of Farmer John’s N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants to count the number of other cows that can see the top of other cows’ heads.Each cow i has a specified height hi

2021-01-27 20:43:13 104

原创 HDU 1572 下沙小面的(2)(DFS)

前文再续,书接上一题。话说当上小面的司机的Lele在施行他的那一套拉客法则以后,由于走的路线太长,油费又贵,不久便亏本了。(真可怜~)于是他又想了一个拉客的办法。对于每一次拉客活动,他一次性把乘客都拉上车(当然也不会超过7个,因为位置只有7个)。然后,Lele计算出一条路线(出于某些目的,Lele只把车上乘客的目的地作为这条路线上的站点),把所有乘客都送到目的地(在这路线上不拉上其他乘客),并且使总路线长度最短。不过Lele每次都要花很多时间来想路线,你能写个程序帮他嘛?Input本题目包含多组测试

2021-01-22 19:03:22 92

原创 #10045. 「一本通 2.2 练习 1」Radio Transmission

给你一个字符串,它是由某个字符串不断自我连接形成的。但是这个字符串是不确定的,现在只想知道它的最短长度是多少。输入格式第一行给出字符串的长度 L,第二行给出一个字符串,全由小写字母组成。输出格式输出最短的长度。样例样例输入 18cabcabca样例输出 13样例说明对于样例,我们可以利用 abc 不断自我连接得到 abcabcabc,读入的 cabcabca 是它的子串。数据范围与提示对于全部数据,1≤L≤10^6。解析:求出字符串的最短循环节的长度;令最短循环节为s1

2020-11-09 20:25:29 410

原创 #103. 子串查找

题目描述:这是一道模板题。给定一个字符串 A 和一个字符串 B,求 B 在 A 中的出现次数。A 和 B 中的字符均为英语大写字母或小写字母。A中不同位置出现的 B 可重叠。输入格式:输入共两行,分别是字符串 A 和字符串 B。输出格式:输出一个整数,表示 B 在 A 中的出现次数。样例输入:zyzyzyzzyz样例输出:3数据范围与提示:1<=A,B的长度<=10^6,A,B仅包含大小写字母解析:利用字符串哈希解题,将字符串看成b进制的数字,将其转换成十进制

2020-11-09 19:37:05 532

原创 #10019. 「一本通 1.3 例 2」生日蛋糕

【题目描述】Mr.W 要制作一个体积为 Nπ 的 M 层生日蛋糕,每层都是一个圆柱体。 设从下往上数第 i 蛋糕是半径为 Ri​,高度为 Hi​ 的圆柱。当 i<M时,要求 Ri​>Ri+1​且 Hi​>Hi+1​。由于要在蛋糕上抹奶油,为尽可能节约经费,我们希望蛋糕外表面(最下一层的下底面除外)的面积 Q最小。 令 Q =Sπ ,请编程对给出的 N 和 M ,找出蛋糕的制作方案(适当的 Ri​ 和 Hi​ 的值),使 S 最小(除 Q 外,以上所有数据皆为正整数)【输入格式】第一

2020-10-30 20:23:37 364

原创 #10003. 「一本通 1.1 例 4」加工生产调度

加工生产调度题目描述某工厂收到了n个产品的订单,这n个产品分别在A、B两个车间加工,并且必须先在A车间加工后才可以到B车间加工。某个产品i在A、B两车间加工的时间分别为Ai、Bi。询问怎样安排这n个产品的加工顺序,才能使总的加工时间最短。这里所说的加工时间是指:从开始加工第一个产品到最后所有的产品都已在A、B两车间加工完毕的时间。输入格式:第一行仅—个数据n(0<n<1000),表示产品的数量。接下来n个数据是...

2020-10-29 20:35:17 418

原创 青蛙约会问题(扩展欧几里得)

两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,你被要求写一个程序来判断这两只青蛙是否能够碰面,会在什么时候碰面。我们把这两只青蛙分别叫做青蛙A和青蛙B,并且

2020-09-27 18:27:17 484

原创 线段树(区间修改,单点查询)懒惰标记

这是一道模板题。给定数列 a[1],a[2],…,a[n]你需要依次进行 q 个操作,操作有两类:1 l r x:给定 l,r,x,对于所有 i∈[l,r],将 a[i] 加上 x(换言之,将 a[l],a[l+1],…,a[r] 分别加上 x);2 l r:给定 l,r求 ∑ri=la[i]的值(换言之,求 a[l]+a[l+1]+⋯+a[r]的值)。Input第一行包含 2 个正整数 n,q表示数列长度和询问个数。保证 1≤n,q≤106。第二行 n个整数 a[1],a[2],…,a[n]表

2020-09-27 17:48:49 333

原创 线段树单点修改区间查询

单点修改区间查询这是一道模板题。给定数列 a[1],a[2],…,a[n],你需要依次进行 qq 个操作,操作有两类:1 i x:给定 i,x,将 a[i] 加上 x;2 l r:给定 l,r,求 ∑ri=la[i]的值(换言之,求 a[l]+a[l+1]+⋯+a[r] 的值)。Input第一行包含 2 个正整数 n,q,表示数列长度和询问个数。保证 1≤n,q≤106。第二行 n 个整数 a[1],a[2],…,a[n]表示初始数列。保证 |a[i]|≤106。接下来 q 行,每行一个操作

2020-09-27 15:49:55 202

原创 Door Man POJ - 1300 (欧拉回路的简单应用)

You are a butler in a large mansion. This mansion has so many rooms that they are merely referred to by number (room 0, 1, 2, 3, etc…). Your master is a particularly absent-minded lout and continually leaves doors open throughout a particular floor of the

2020-09-26 10:56:44 223

原创 第三周上动态规划(跑跑卡丁车 HDU - 1494 )

跑跑卡丁车是时下一款流行的网络休闲游戏,你可以在这虚拟的世界里体验驾驶的乐趣。这款游戏的特别之处是你可以通过漂移来获得一种加速卡,用这种加速卡可以在有限的时间里提高你的速度。为了使问题简单化,我们假设一个赛道分为L段,并且给你通过每段赛道的普通耗时Ai和用加速卡的耗时Bi。加速卡的获得机制是:普通行驶的情况下,每通过1段赛道,可以获得20%的能量(N2O).能量集满后获得一个加速卡(同时能量清0).加速卡最多可以储存2个,也就是说当你有2个加速卡而能量再次集满,那么能量清零但得不到加速卡。一个加速卡只能维

2020-09-26 09:45:41 176

原创 第二周下最短路spfa算法(Candies POJ - 3159)

During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large bag of candies and had flymouse distribute them. All the kids loved candies very much and often compared the num

2020-09-26 09:09:15 99

原创 第二周上二分图(Oil Skimming HDU - 4185)

Thanks to a certain “green” resources company, there is a new profitable industry of oil skimming. There are large slicks of crude oil floating in the Gulf of Mexico just waiting to be scooped up by enterprising oil barons. One such oil baron has a special

2020-09-25 22:51:28 78

原创 第一周下多重背包(Cash Machine POJ - 1276 )

A Bank plans to install a machine for cash withdrawal. The machine is able to deliver appropriate @ bills for a requested cash amount. The machine uses exactly N distinct bill denominations, say Dk, k=1,N, and for each denomination Dk the machine has a sup

2020-09-25 21:49:31 108

原创 第一周下记忆化搜索(滑雪)

Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813 12 11 10 9一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。在上面的例子中,一条可滑行的滑坡为24-1

2020-09-25 17:46:00 89

原创 第一周上H题搜索(Infinite Maze)

We’ve got a rectangular n × m-cell maze. Each cell is either passable, or is a wall (impassable). A little boy found the maze and cyclically tiled a plane with it so that the plane became an infinite maze. Now on this plane cell (x, y) is a wall if and onl

2020-09-25 16:57:05 162

原创 Oulipo HDU - 1686(KMP算法理解)

The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter ‘e’. He was a member of the Oulipo group. A quote from the book:Tout avait Pair normal, mais tout s’affirmait faux. Tout avait Fair normal, d’abord, puis sur

2020-08-09 16:06:27 237

原创 最长回文(马拉车算法模板解析)

最长回文给出一个只由小写英文字符a,b,c…y,z组成的字符串S,求S中最长回文串的长度.回文就是正反读都是一样的字符串,如aba, abba等Input输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c…y,z组成的字符串S两组case之间由空行隔开(该空行不用处理)字符串长度len <= 110000Output每一行一个整数x,对应一组case,表示该组case的字符串中所包含的最长回文长度.Sample InputaaaaababSample

2020-08-07 19:08:41 236

原创 Aladdin and the Flying Carpet(唯一分解定律)

It’s said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first mystery.Aladdin was about to enter to a magical cave, led by the evil sorcerer who disguised himself

2020-05-29 21:00:45 234

原创 Leading and Trailing

You are given two integers: n and k, your task is to find the most significant three digits, and least significant three digits of nk.InputInput starts with an integer T (≤ 1000), denoting the number of test cases.Each case starts with a line containing

2020-05-28 21:24:27 128

原创 Bi-shoe and Phi-shoe

Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a very popular coach for his success. He needs some bamboos for his students, so he asked his assistant Bi-Shoe to go to the market and buy them. Plenty of Bamboos of all po

2020-05-28 21:13:22 154

原创 Mathematically Hard(欧拉函数打表+前缀和)

Mathematically some problems look hard. But with the help of the computer, some problems can be easily solvable.In this problem, you will be given two integers a and b. You have to find the summation of the scores of the numbers from a to b (inclusive). T

2020-05-26 20:28:00 165

原创 K-th Not Divisible by n

You are given two positive integers nn and kk. Print the kk-th positive integer that is not divisible by nn.For example, if n=3n=3, and k=7k=7, then all numbers that are not divisible by 33 are: 1,2,4,5,7,8,10,11,13…1,2,4,5,7,8,10,11,13…. The 77-th number

2020-05-16 22:04:21 286

原创 哈夫曼树

An entropy encoder is a data encoding method that achieves lossless data compression by encoding a message with “wasted” or “extra” information removed. In other words, entropy encoding removes inform...

2020-04-30 21:20:53 244

原创 求后序

A binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoint binary trees called the left and right subtrees. There are three most important ways in which th...

2020-04-30 21:02:24 111

原创 求前序

给出一棵二叉树的中序与后序排列。求出它的先序排列。(约定树结点用不同的大写字母表示,长度 \le≤ 88)。输入格式22 行,均为大写字母组成的字符串,表示一棵二叉树的中序与后序排列。输出格式11 行,表示一棵二叉树的先序。输出时每行末尾的多余空格,不影响答案正确性样例输入BADCBDCA样例输出ABCD二叉树:前序:根左右中序:左根右后序:左右根思路:先根据后序最后...

2020-04-29 21:41:45 118

原创 二分最大匹配(匈牙利算法)

RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partner,PrincessSnow愿意和水域浪子或伪酷儿做partner。考虑...

2020-04-18 22:02:34 248

原创 01背包

电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。Input多组数据。对于每组数据:第一行为正整数n,表示菜的...

2020-04-18 21:47:27 165

原创 用queue队列解决bfs问题

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

2020-04-18 21:40:50 269

原创 第八周训练F题

The next lecture in a high school requires two topics to be discussed. The ii-th topic is interesting by aiai units for the teacher and by bibi units for the students.The pair of topics ii and jj (i&...

2020-04-07 20:55:34 502

原创 A - Platforms Jumping

There is a river of width nn. The left bank of the river is cell 00 and the right bank is cell n+1n+1 (more formally, the river can be represented as a sequence of n+2n+2 cells numbered from 00 to n+1...

2020-04-06 22:15:24 176

空空如也

空空如也

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

TA关注的人

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