刷题笔记
,(逗号)
这个作者很懒,什么都没留下…
展开
-
A Question of Ingestion
A Question of IngestionStan Ford is a typical college graduate student, meaning that one of the most important things on his mindis where his next meal will be. Fortune has smiled on him as he’s been invited to a multi-course barbecueput on by some of t原创 2020-11-28 15:10:46 · 135 阅读 · 0 评论 -
[蓝桥杯2017初赛]方格分割
题目描述6x6的方格,沿着格子的边线剪开成两部分。要求这两部分的形状完全相同。如图就是可行的分割法。试计算:包括这3种分法在内,一共有多少种不同的分割方法。注意:旋转对称的属于同一种分割法。输出一个整数表示答案题解一看就是用dfs做,这个题用方格的角度去想很难想出全部的答案。要换个角度,看方格线,假设左上角的坐标是(0,0),那么右下角就是(6,6),进行dfs,走的时候中心对称点也要进行访问,一旦走到边界上,即(x == 0 || y == 0 || x == 6 || y == 6),原创 2020-10-11 18:00:13 · 207 阅读 · 0 评论 -
UCF Local Programming Contest 2019(Practice)
Anya’s Favorite CDAnya’s Favorite CDA few years ago, Arup started submitting problems to the UCF Local Contest regarding herdaughter Anya’s CD requests. Unfortunately, his latest question wasn’t good enough to makethe cut for the 2019 UCF Local Contest.原创 2020-07-31 22:39:03 · 328 阅读 · 0 评论 -
HDU-4080 哈希+二分
hdu-4080#include<bits/stdc++.h>#define ull unsigned long longusing namespace std;const int maxn = (int)4e4 + 10;int n,len;char s[maxn];ull has[maxn];ull p = 2333,a[maxn];bool judge(int x){ map<int,int> mp; ull res; for (i转载 2020-07-23 15:19:16 · 223 阅读 · 0 评论 -
ICPC North America Qualifier Contest 2015
ICPC North America Qualifier Contest 2015A. All about that baseInputOutput样例输入样例输出题解:B. Bobby's BetInputOutput样例输入1样例输出1样例输入2样例输出2题解:C. Cantina of BabelInputOutput样例输入1样例输出1样例输入2样例输出2==题解:==D. Circui...原创 2020-04-21 17:54:33 · 540 阅读 · 0 评论 -
判断四个点是否为正方形
//要考虑正方形是倾斜的情况#include<iostream>#include<algorithm>#include<cmath>using namespace std;struct point{ double x, y;} a[4];bool cmp(point a, point b){ if (a.x != b.x) ...转载 2020-03-31 23:46:56 · 1240 阅读 · 0 评论 -
[蓝桥杯]矩形面积交
问题描述 平面上有两个矩形,它们的边平行于直角坐标系的X轴或Y轴。对于每个矩形,我们给出它的一对相对顶点的坐标,请你编程算出两个矩形的交的面积。 输入格式 输入仅包含两行,每行描述一个矩形。 在每行中,给出矩形的一对相对顶点的坐标,每个点的坐标都用两个绝对值不超过10^7的实数表示。 输出格式 输出仅包含一个实数,为交的面积,保留到小数后两位。样例输入1 1 ...原创 2020-03-30 20:59:03 · 68 阅读 · 0 评论 -
[蓝桥杯2018初赛]日志统计
题目描述小明维护着一个程序员论坛。现在他收集了一份"点赞"日志,日志共有N行。其中每一行的格式是:ts id。表示在ts时刻编号id的帖子收到一个"赞"。现在小明想统计有哪些帖子曾经是"热帖"。如果一个帖子曾在任意一个长度为D的时间段内收到不少于K个赞,小明就认为这个帖子曾是"热帖"。具体来说,如果存在某个时刻T满足该帖在[T, T+D)这段时间内(注意是左闭右开区间)收到不少于K个赞...转载 2020-03-29 23:30:00 · 243 阅读 · 0 评论 -
[蓝桥杯2019初赛]A组
题目描述给定一个长度为N 的数组A = [A1, A2,…,AN],数组中有可能有重复出现的整数。现在小明要按以下方法将其修改为没有重复整数的数组。小明会依次修改A2,A3,…, AN。当修改Ai 时,小明会检查Ai 是否在A1~ Ai-1 中出现过。如果出现过,则小明会给Ai 加上1 ;如果新的Ai 仍在之前出现过,小明会持续给Ai加1 ,直到Ai没有在A1~ Ai-1中出现过。当...原创 2020-03-29 16:38:05 · 483 阅读 · 3 评论 -
[蓝桥杯2019初赛]后缀表达式
[蓝桥杯2019初赛]后缀表达式时间限制: 1 Sec 内存限制: 256 MB题目描述给定N 个加号、M 个减号以及N + M + 1 个整数A1,A2,…,AN+M+1小明想知道在所有由这N 个加号、M 个减号以及N + M +1 个整数凑出的合法的后缀表达式中,结果最大的是哪一个?请你输出这个最大的结果。例如使用1 2 3 + -,则“2 3 + 1 -” 这个后缀表达式结果...原创 2020-03-28 21:16:59 · 380 阅读 · 0 评论 -
Efficient Exchange Benelux Algorithm Programming Contest 2019
Efficient Exchange您最近在银行获得了一份新奇的货币工作。人们可以在这里付款,并以各种奇怪的货币存入或提取钱。在工作的第一天,您会帮助来自奈梅贾的客户,奈梅贾是一个微不足道的小国,以巨大的硬币而闻名,其价值等于10的幂,即1、10、100、1000等。该客户希望相当大的一笔付款,您不希望携带所有这些硬币往返金库。因此,您决定先思考。您和客户一样都有大量的尼吉米亚硬币储备(大多...转载 2020-03-23 00:01:38 · 137 阅读 · 0 评论 -
UCF Local Programming Contest 2012 "D The Clock Algorithm"
The Clock Algorithm题意:当时我做的时候我真的捋不顺。意思是加载页面到窗口,若该页面没有被加载到任何一个窗口上,就将页面加载到一个空窗口上;若没有空窗口,就沿着指针向下寻找标记为old的窗口,若指针指向的窗口上的页面标记为new,就修改为old,继续向下寻找,直到找到一个标记为old,就将该页面放到这个窗口上,并标记为new。#include<cstdio>#i...原创 2020-03-07 18:22:42 · 278 阅读 · 0 评论 -
素数的应用
唯一素因子分解定理:合数a仅能以一种方式,写成如下的乘积形式:a=p1e1 * p2e2 ……prer 其中pi为素数,p1<p2<…<pr,且ei为正整数如果正整数n分解质因子的结果为n=p1e1p2e2…prer,则n的约数个数为: (e1+1)(e2+1)…(er+1)所有约数之和为:(1+p1+p12+…+p1e1)(1+p2+p22 +…+p2e2)…(1...原创 2019-10-19 21:24:18 · 530 阅读 · 0 评论 -
N!最后的非零位
N!最后的非0位5! = 1 * 2 * 3 * 4 * 5 = 120,所以5!的最后面的非零位是2;7! = 1 * 2 * 3 * 4 * 5 * 6 * 7 = 5040,所以最后面的非零位是4。1234!最后1个非0位是多少?#include<cstdio>#include<cstring>int main(){ int n,ans=1; ...原创 2019-10-19 21:04:09 · 178 阅读 · 0 评论 -
求N!末尾0的个数
思路:N!=(123456、、、N)=5 * 5 * 5 * 5 *(1、2、、、、、)1234!的尾数0的个数计算如下:1234/5=246246/5=4949/5=99/5=11/5=0246+49+9+4+0=305所以1234!的尾数0的个数第305原理:(1)行得到的是1~1234中因子含有5的个数【即 5*(12345*、、、246)在1乘到1234中,5、10、15...原创 2019-10-19 20:30:58 · 266 阅读 · 0 评论 -
Bear and Compressing 【CodeForces 653B】
直接暴力所有可能的情况#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<cmath>#include<map>using namespace std;const int Max=10;map<ch...原创 2019-08-21 23:16:29 · 118 阅读 · 0 评论 -
Maximum Median 【CodeForces 1201C】
Maximum Median题意:有k次机会将某个数加1,问用完k次机会后,最大的中位数是多少。先找到未使用机会的中位数,只考虑中位数及其以后的数。#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>using namespace std;cons...原创 2019-08-21 22:52:31 · 117 阅读 · 0 评论 -
Friday the Thirteenth 黑色星期五
日子问题Description13号又是一个星期5。13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数。给出N年的一个周期,要求计算1900年1月1日至1900+N-1年12月31日中十三号落在周一到周日的次数,N为正整数且不大于400.这里有一些你要知道的:1900年1月1日是星期一.4,6,11和9月有30天.其他月份除了2月都有31天...原创 2019-08-06 23:56:37 · 145 阅读 · 0 评论 -
Calendar【计算日期】
CalendarTime Limit: 1 SecMemory Limit: 64 MBDescription A calendar is a system for measuring time, from hours and minutes, to months and days, and finally to years and centuries. The ter...原创 2019-08-07 07:36:45 · 384 阅读 · 0 评论 -
Broken Necklace
题目连接这种思想值得学习#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>using namespace std;char a[400];int len;int change(int i){ if(i<0) i+...原创 2019-08-07 08:46:18 · 66 阅读 · 0 评论 -
Prime Palindromes 回文质数
Description 因为151即是一个质数又是一个回文数(从左到右和从右到左是看一样的),所以 151 号是回文质数。写一个程序来找出范围[a,b](5 <= a < b <= 100,000,000)间的所有回文质数;Input 第 1 行: 二个整数 a 和 b Output输出一个回文质数的列表,一行一个。Sample Input5 500Sample ...原创 2019-08-07 11:06:31 · 185 阅读 · 0 评论 -
A Bug
A bug Time Limit: 1 Sec Memory Limit: 125 MBSescriptionBackground Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes ...原创 2019-08-11 00:09:43 · 565 阅读 · 0 评论 -
Patterns and Pictures
Description Fabrics often have repeating patterns on them, such as a tessellation of carrots and bats. A given image, such as a carrot in the above example, takes up a certain number of square inc...原创 2019-08-11 09:53:50 · 111 阅读 · 0 评论 -
会场安排问题
会场安排问题Description假设要在足够多的会场里安排一批活动,并希望使用尽可能少的会场。设计一个有效的贪心算法进行安排。(这个问题实际上是著名的图着色问题。若将每一个活动作为图的一个顶点,不相容活动间用边相连。使相邻顶点着有不同颜色的最小着色数,相应于要找的最小会场数。) 对于给定的k个待安排的活动,计算使用最少会场的时间表。Input输入数据的第一行有1 个正整数k(k≤1000...原创 2019-09-26 19:41:25 · 88 阅读 · 0 评论 -
回家 【SDIBT 2337】
最短路,直接用map+Floyd直接暴力就行#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<map>using namespace std;typedef long long ll;const int INF=0x...原创 2019-08-19 21:30:58 · 126 阅读 · 0 评论 -
Marvolo Gaunt's Ring 【CodeForces 855B】
求p * i + q * j + r * k(i<=j<=k)的最大值虽然题中给的时间比较长但还是不可以用直接暴力用三次for循环,一定可以用一遍循环过的。下面这种方法一定要牢记,感觉经常用到。#include<cstdio>#include<cstring>#include<cstdlib>#include<iostream>...原创 2019-08-19 21:16:34 · 149 阅读 · 0 评论 -
Approximating a Constant Range【CodeForces 602B】
题意:找最长子串,使串中每个元素之间的差值都小于等于1;#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<cmath>#include<map>using namespace std;const int ...原创 2019-08-21 21:21:32 · 176 阅读 · 0 评论 -
Duff and Weight Lifting【CodeForces 587A】
题意:举重,计算她放下的次数。如果找不到wi+wi+1+…!=2k,那么将举起的重量全部放下,重新开始。21+21=22;22+22=23;23+23=24;……#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<cmat...原创 2019-08-21 21:33:00 · 156 阅读 · 0 评论 -
Chain Reaction【CodeForces 607A】
题意:从最后一个灯塔开始倒(假设为x),x不倒,仍然存在,如果前边有灯塔被压倒,则该灯塔作废,所有的灯塔都这样过一遍。问:最多如果在最后一个灯塔的后面再加一个灯塔,高度随意,最多可以保留多少灯塔。#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#in...原创 2019-08-21 21:47:32 · 204 阅读 · 0 评论 -
Restaurant Tables【CodeForces 828A】+Game of the Rows【CodeForces 839B】
感觉这两个题很像,解法相同。Restaurant Tables题意:给顾客安排座位,如果顾客是一个人,就安排一个位置的,如果没有就安排两个座位的,但只占一个位置。顾客是两个人就安排两个位置。#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#def...原创 2019-08-21 22:04:55 · 171 阅读 · 2 评论 -
City Day 【CodeForces 1199A】
CodeForces 1199A题意:求以i(1<=i<=n)为中心,前x天的雨量都大于第i天的雨量,后y天的雨量都大于第i天的雨量,输出最先出现的,满足条件的那一天。#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include&...原创 2019-08-21 22:47:37 · 175 阅读 · 0 评论 -
poj 2985 并查集+线段树 线段树求第k大数 The k-th Largest Group
最重要的思想是,线段树里存的是值为L到R的个数,即在L-R这段区间内,值为L,L+1,L+2,L+3…R的个数。#include<cstdio>#include<cstring>const int maxn = 2e5+10;#define mid (l+r)>>1#define lson l,m,rt<<1#define rson m+...原创 2019-08-03 23:16:10 · 72 阅读 · 0 评论