![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM比赛
wastill
坚持,是一切拥有的基石。
展开
-
位运算日常总结
在平常的练习中位运算时常表现出一些比较惊艳的操作,这里做一个总结,以后遇到也会添上,如果小伙伴们有什么惊艳的操作或者建议这里没有提到,欢迎大家私信,或者评论。共同进步!1.n&(n-1)去掉n的二进制中最右边的一个1。2.n&(n-1)==0判断n是不是2的乘方。3.m<<n相当于m*(2的n次方)。4.m>>n相当于m/(2的n次方)。5.n&g...原创 2019-01-21 16:49:14 · 117 阅读 · 0 评论 -
M - A Mini Locomotive寒假练习2-M
来源:POJ - 1976 A train has a locomotive that pulls the train with its many passenger coaches. If the locomotive breaks down, there is no way to pull the train. Therefore, the office of railroads decid原创 2018-02-04 09:07:31 · 112 阅读 · 0 评论 -
K - Curling 2.0寒假练习2-K
来源:POJ - 3009 On Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a squ原创 2018-02-04 08:42:13 · 177 阅读 · 0 评论 -
J - Red and Black 寒假练习1-J
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can’原创 2018-01-27 19:02:23 · 270 阅读 · 0 评论 -
H - Farm Irrigation寒假练习1-H
Benny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square has a different type of原创 2018-01-27 18:52:06 · 272 阅读 · 0 评论 -
F - Knight Moves 寒假练习1-F
A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessbo原创 2018-01-27 17:46:29 · 259 阅读 · 0 评论 -
D - Parentheses Balance寒假练习1-D
You are given a string consisting of parentheses () and []. A string of this type is said to be correct: (a) if it is the empty string (b) if A and B are correct, AB is correct, (c) if A is correct原创 2018-01-27 17:39:54 · 190 阅读 · 0 评论 -
C - Oil Deposits寒假练习1-c
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 th原创 2018-01-27 17:31:30 · 224 阅读 · 0 评论 -
poj1852
Ants Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21449 Accepted: 8793 DescriptionAn army of ants walk on a horizontal pole of length l cm, each with a constant speed of原创 2018-01-31 14:02:45 · 631 阅读 · 1 评论 -
最长公共子序列
给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的)。 比如两个串为:abcicba abdkscabab是两个串的子序列,abc也是,abca也是,其中abca是这两个字符串最长的子序列。 Input 第1行:字符串A 第2行:字符串B (A,B的长度 <= 1000) Output 输出最长的子序列,如果有多个,随意输出1个。 Input示例 abcicba原创 2017-12-02 21:09:10 · 234 阅读 · 0 评论 -
hdu2092
水货刷水题,,,,,,,, 整数解Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 37617 Accepted Submission(s): 13241Problem Description 有二个整数,它们加起来等于某个整数,原创 2017-11-18 11:08:48 · 375 阅读 · 2 评论 -
hdu1106
很长时间没刷题了,从简单的开始吧,,,,,,,,,水货一个,,,,, 排序Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 63512 Accepted Submission(s): 18779Problem Description原创 2017-11-18 11:00:22 · 165 阅读 · 0 评论 -
N - Ubiquitous Religions 寒假练习2-N
来源:poj2524 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 uni原创 2018-02-04 09:13:12 · 123 阅读 · 0 评论 -
L - Charm Bracelet 寒假练习2-L
来源:poj3624 Bessie has gone to the mall’s jewelry store and spies a charm bracelet. Of course, she’d like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each cha原创 2018-02-04 09:21:32 · 134 阅读 · 0 评论 -
zoj-3872——Beauty of Array
Edward has an array A with N integers. He defines the beauty of an array as the summation of all distinct integers in the array. Now Edward wants to know the summation of the beauty of all contiguous ...原创 2018-04-29 17:23:21 · 253 阅读 · 0 评论 -
物资调度(dp)
题目描述某地区发生了地震,灾区已经非常困难,灾民急需一些帐篷、衣物、食品和血浆等物资。可通往灾区的道路到处都是塌方,70%以上的路面损坏,桥梁全部被毁。国家立即启动应急预案,展开史上最大强度的非作战式的空运行动,准备向灾区投放急需物资。一方有难,八方支援。现在已知有N个地方分别有A1,A2,….,An个物资可供调配。目前灾区需要物资数量为M。 现在,请你帮忙算一算,总共有多少种物质调度...原创 2018-04-29 17:01:12 · 262 阅读 · 0 评论 -
求多边形面积
在计算几何中经常遇到要求多边形面积的题目,这里总结一些模板。 对于多边形ABCDE的面积,我们可以看做2个多边形面积的差,即,Sabcde=Soab+Soae+Soed-Socd-Socb. 根据二维向量的叉乘我们可以求出三角形oab的面积 即Soab=0.5*|oa叉乘ob|=0.5*|A.x*B.y-A.y*B.x|. 同理。 Sabcde=Soab+Soae+Soed-Socd...原创 2018-04-13 11:42:56 · 1059 阅读 · 0 评论 -
动态规划——Little Red Riding Hood
题目描述Once upon a time, there was a little girl. Her name was Little Red Riding Hood. One day, her grandma was ill. Little Red Riding Hood went to visit her. On the way, she met a big wolf. “That's a ...原创 2018-04-22 16:28:34 · 290 阅读 · 0 评论 -
poj1659-Havel-Hakimi定理
Havel-Hakimi定理: 有非负整数组成的非增序列s(代表顶点的度数):d1,d2······dn(n>=2,d1>=1,di>=0)是可图的。 例如: s:7,6,5,5,2,1,2,1 判断s是否可图,只需先将s排序,得s:7,6,5,5,2,2,1,1.第一项为7,所以7后面的7项全部减一,7舍去,排序后得s:5,4,4,1,1,0,0.第一项为5,第一项去掉...原创 2018-04-16 09:33:29 · 233 阅读 · 0 评论 -
素数密度——区间筛法(详解)
问题 : 找素数时间限制: 1 Sec 内存限制: 128 MB 提交: 14 解决: 3 [提交][状态] 题目描述算法提高 找素数 时间限制:1.0s 内存限制:256.0MB 问题描述 给定区间[L, R] , 请计算区间中素数的个数。 输入格式 两个数L和R。 输出格式 一行,区间中素数的个数。 样例输入 2 ...原创 2018-03-31 12:48:44 · 3875 阅读 · 1 评论 -
简单的博弈
这里转载一下别人的博客:http://blog.csdn.net/ac_gibson/article/details/41624623 另一个大佬的https://www.cnblogs.com/kuangbin/archive/2011/08/28/2156426.html 链接:https://www.nowcoder.net/acm/contest/75/D 来源:牛客网巴什博奕:原创 2018-02-04 20:13:22 · 1427 阅读 · 0 评论 -
容斥定理
容斥定理: 要计算几个集合并集的大小,我们要先将所有单个集合的大小计算出来,然后减去所有两个集合相交的部分,再加回所有三个集合相交的部分,再减去所有四个集合相交的部分,依此类推,一直计算到所有集合相交的部分。 例题: 链接:https://www.nowcoder.net/acm/contest/75/G 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C+原创 2018-02-04 19:44:43 · 353 阅读 · 0 评论 -
大数阶乘
链接:https://www.nowcoder.net/acm/contest/75/E 来源:牛客网时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format: %lld 题目描述 给定一个整数N(0≤N≤10000),求取N的阶乘 输入描述: 多个测试数据,每个测试数据输入一个数N 输出描述: 每组原创 2018-02-04 20:17:28 · 489 阅读 · 0 评论 -
I - Word Reversal
For each list of words, output a line with each word reversed without changing the order of the words.This problem contains multiple test cases!The first line of a multiple input is an integer N,原创 2018-02-04 09:38:43 · 394 阅读 · 0 评论 -
D - Girls and Boys寒假练习3-D
the second year of the university somebody started a study on the romantic relations between the students. The relation ��romantically involved�� is defined between one girl and one boy. For the study原创 2018-02-04 09:34:42 · 251 阅读 · 0 评论 -
A Math Problem ——2017ACM/ICPC广西邀请赛
You are given a positive integer n, please count how many positive integers k satisfy kk≤nkk≤n. Input There are no more than 50 test cases. Each case only contains a positivse integer n in a line. 1原创 2017-10-05 13:46:36 · 413 阅读 · 0 评论 -
N的N次方
问题 H: N的N次方时间限制: 1 Sec 内存限制: 32 MB提交: 57 解决: 17[提交][状态][讨论版]题目描述现给你一个正整数N,请问N^N的最左边的数字是什么?输入输入包含多组测试数据。每组输入一个正整数N(N输出对于每组输入,输出N^N的最左边的数字。样例输入34样例输出22提示[提交][状态][讨论版]原创 2017-07-23 08:58:46 · 532 阅读 · 0 评论 -
最长非上升/非下降子序列(O(nlogn)非连续)
直接上代码,在其他大佬那看的·,当做个模板。#include<stdio.h>#define N 101000int s[N],a[N],d[N];int f1(int x,int l,int r){ int m; while(l<r) { m=(l+r)/2; if(s[m]>x) r=m; else原创 2017-10-19 16:13:44 · 685 阅读 · 0 评论 -
欧几里得游戏(简单博弈)
问题 D: 欧几里得游戏时间限制: 1 Sec 内存限制: 32 MB提交: 27 解决: 6[提交][状态][讨论版]题目描述小明和小红在玩欧几里得游戏。他们从两个自然数开始,第一个玩家小明,从两个数的较大数中减去较小数的尽可能大的正整数倍,只要差为非负即可。然后,第二个玩家小红,对得到的两个数进行同样的操作,然后又是小明。就这样轮流进行游戏,直至某个玩家将较大数减去较小原创 2017-07-24 14:22:04 · 3728 阅读 · 3 评论 -
迷宫问题
问题 C: 迷宫问题时间限制: 1 Sec 内存限制: 32 MB提交: 72 解决: 17[提交][状态][讨论版]题目描述小明置身于一个迷宫,请你帮小明找出从起点到终点的最短路程。小明只能向上下左右四个方向移动。输入输入包含多组测试数据。输入的第一行是一个整数T,表示有T组测试数据。每组输入的第一行是两个整数N和M(1接下来N行,每行输入M个字符,每原创 2017-07-24 11:50:16 · 530 阅读 · 0 评论 -
木棒
问题 H: 木棒时间限制: 1 Sec 内存限制: 32 MB提交: 40 解决: 11[提交][状态][讨论版]题目描述现有n根木棒,已知它们的长度和重量。要用一部木工机一根一根地加工这些木棒。该机器在加工过程中需要一定的准备时间,是用于清洗机器,调整工具和模板的。木工机需要的准备时间如下:(1)第一根木棒需要1min的准备时间;(2)在加工了一根长为l,重为w的原创 2017-07-23 17:30:19 · 968 阅读 · 0 评论 -
迷宫问题
问题 C: 迷宫问题时间限制: 1 Sec 内存限制: 32 MB提交: 72 解决: 17[提交][状态][讨论版]题目描述小明置身于一个迷宫,请你帮小明找出从起点到终点的最短路程。小明只能向上下左右四个方向移动。输入输入包含多组测试数据。输入的第一行是一个整数T,表示有T组测试数据。每组输入的第一行是两个整数N和M(1接下来N行,每行输入M个字符,每原创 2017-07-23 17:28:35 · 409 阅读 · 0 评论 -
丑数
问题 A: 丑数时间限制: 1 Sec 内存限制: 32 MB提交: 20 解决: 4[提交][状态][讨论版]题目描述如果一个数的素因子只包含2,3,5或7,那么我们把这种数叫做丑数。序列1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27...展示了前20个丑数。请你编程寻找这个序列中的第n个元素。输入输入包含原创 2017-07-23 17:15:17 · 2478 阅读 · 1 评论 -
18岁生日
问题 D: 18岁生日时间限制: 1 Sec 内存限制: 32 MB提交: 24 解决: 10[提交][状态][讨论版]题目描述zzq的18岁生日就要到了,他当然很开心,可是他突然想到一个问题,是不是每个人从出生开始,到达18岁生日时所经过的天数都是一样的呢?似乎并不全都是这样,所以他想请你帮忙计算一下他和他的几个朋友从出生到达18岁生日所经过的总天数,让他好来比较一下。原创 2017-07-23 17:08:07 · 234 阅读 · 0 评论 -
分梨
问题 G: 分梨时间限制: 1 Sec 内存限制: 32 MB提交: 26 解决: 9[提交][状态][讨论版]题目描述zzq非常喜欢吃梨,有一天他得到了ACMCLUB送给他的一筐梨子。由于他比较仗义,就打算把梨子分给好朋友们吃。现在他要把M个梨子放到N个盘子里面(我们允许有的盘子为空),你能告诉zzq有多少种分法吗?(请注意,例如有三个盘子,我们将5,1,1和1,1,5,原创 2017-07-23 08:50:16 · 730 阅读 · 0 评论 -
解题报告
问题 D: 18岁生日 时间限制: 1 Sec 内存限制: 32 MB 提交: 24 解决: 10 [提交][状态][讨论版] 题目描述 zzq的18岁生日就要到了,他当然很开心,可是他突然想到一个问题,是不是每个人从出生开始,到达18岁生日时所经过的天数都是一样的呢?似乎并不全都是这样,所以他想请你帮忙计算一下他和他的几个朋友从出生到达18岁生日所经过的总天数,让他好来比较一下。原创 2017-07-22 17:46:15 · 276 阅读 · 0 评论 -
sdacm-test0076-20170427
问题 A: 当总统时间限制: 1 Sec 内存限制: 32 MB提交: 49 解决: 23[提交][状态][讨论版]题目描述小明想当丑国的总统,丑国大选是按各州的投票结果来确定最终的结果的,如果得到超过一半的州的支持就可以当选,而每个州的投票结果又是由该州选民投票产生的,如果某个州超过一半的选民支持小明,则他将赢得该州的支持。现在给出每个州的选民人数,请问小明至原创 2017-05-02 21:45:47 · 217 阅读 · 0 评论 -
sdacm-201704
问题 G: Two Bags of Bread时间限制: 5 Sec 内存限制: 128 MB提交: 26 解决: 11[提交][状态][讨论版]题目描述Lialosiu喜欢吃男饭面包店的面包,曾经创下一天吃15袋面包的记录。校庆那天,Lialosiu又去买了两袋面包,第一袋有x(x>=1)个面包,第二袋有y(y>=1)个面包。他是一个很粗心的人,以至于他把第一原创 2017-05-02 21:37:26 · 420 阅读 · 0 评论 -
sdacm-test013-20170502
问题 A: 回形取数时间限制: 1 Sec 内存限制: 128 MB提交: 14 解决: 14[提交][状态][讨论版]题目描述回形取数就是沿矩阵的边取数,若当前方向上无数可取或已经取过,则左转90度。一开始位于矩阵左上角,方向向下。输入格式输入输入第一行是两个不超过200的正整数m, n,表示矩阵的行和列。接下来m行每行n个整数,表示这原创 2017-05-02 21:41:09 · 309 阅读 · 0 评论 -
dp01背包——A - Bone Collector
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave … The bone collecto原创 2017-07-28 08:52:00 · 203 阅读 · 0 评论