
思维
creator平
期望破茧成蝶时的飞翔,向往突破蝉蛹后的鸣叫。
展开
-
Gym - 102055G——Pastoral Life in Stardew Valley
题目链接:https://vjudge.net/problem/2219900/origin题意:一块x*y大小的田地,放一个稻草人,稻草人大小任意,要求稻草人要被草包围,求有多少种放法思路:对于一列,选四个点,外边两个当草的边界,里面两个当稻草人大小,C(x,4),还漏了一种稻草人列长度为1的情况,再加上外边选两个点,里边选一个点,C(x,3)。行同理,最后结果行和列的情况相乘(C(...原创 2019-11-13 09:37:48 · 319 阅读 · 0 评论 -
CodeForces - 936C ——Lock Puzzle
题目链接:https://vjudge.net/contest/336724#problem/C题意:只能进行一种操作,选定一个x,最后x个字符翻转,然后把翻转后的字符放到最前面,求是否能在6100次内把s串通过上述操作变成t串#include<bits/stdc++.h>using namespace std;#define ll long longint n;ch...原创 2019-10-31 21:11:15 · 189 阅读 · 0 评论 -
CodeForces - 955C——Sad powers
题目链接:https://vjudge.net/contest/336724#problem/I题意:给出一个区间L~R,问在里面能找到多少个x满足L ≤ x ≤ R且x = ap (a > 0,p > 1)思路:找出a的3次幂以上的数,可以缩小为1e6,2次幂的数可以用开根号求,3次幂以上的去个重#include<bits/stdc++.h>#de...原创 2019-10-31 21:08:50 · 152 阅读 · 0 评论 -
CodeForces - 999D——Equalize the Remainders
题目链接:https://vjudge.net/contest/336720#problem/J题意:给出一个序列A一共n个数,给出一个m是n的因子。每次可以进行一个操作,使得A【i】+1。求至少进行多少次操作可以满足序列A中每个元素%m后的序列恰好有n/m个【0~m-1】.#include<stdio.h>#include<algorithm>#includ...原创 2019-10-30 09:20:40 · 236 阅读 · 0 评论 -
Mislove Has Lost an Array
题目链接:http://codeforces.com/contest/1204/problem/B日常沙雕,看到个n上限是500直接跑去用python打大数,佛了自己minn=int(0)maxx=int(0)er=1n,l,r=map(int,input().split())while(n): if(l>0): minn+=er if(r&...原创 2019-08-21 11:44:54 · 173 阅读 · 0 评论 -
Codeforces Round #580 (Div. 2)——Almost Equal
You are given integernn. You have to arrange numbers from11to2n2n, using each of them exactly once, on the circle, so that the following condition would be satisfied:For everynnconsecutive num...原创 2019-08-20 11:03:32 · 419 阅读 · 2 评论 -
Bear and Forgotten Tree 3
题目链接:http://codeforces.com/contest/658/problem/C思路:特判d==1的情况#include<string.h>#include<stdio.h>#include<algorithm>using namespace std;int n,d,h;int main(){ scanf("%d%d...原创 2019-08-10 10:36:49 · 262 阅读 · 0 评论 -
Bear and Displayed Friends
题目链接:http://codeforces.com/contest/658/problem/B思路:本来想着如果sort过不了就用冒泡的,因为在已经排序好的状态下,加入一个数,冒泡只需要冒一次,但是它过了,那就算了吧.......#include<string.h>#include<stdio.h>#include<map>#include&l...原创 2019-08-09 18:04:33 · 206 阅读 · 0 评论 -
UVA - 10755——Garbage Heap(三维前缀和)
题目链接:https://vjudge.net/problem/UVA-10755见白书54页#include<algorithm>#include<string.h>#include<stdio.h>#define ll long longusing namespace std;ll t,a,b,c;ll A[25][25][25];v...原创 2019-06-07 12:52:15 · 247 阅读 · 0 评论 -
UVALive - 3695 ——Distant Galaxy(思维,优化)
题目链接:https://vjudge.net/problem/UVALive-3695题意:给出n个点,找出一个矩形,使得所有的点恰好在矩形的边上的个数最多,求最多是多少。白书53页#include<algorithm>#include<stdio.h>#include<string.h>using namespace std;pair&...原创 2019-06-01 21:19:20 · 187 阅读 · 0 评论 -
Codeforces Round #561 (Div. 2) C. A Tale of Two Lands (二分)
C. A Tale of Two Landstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe legend of the foundation of Vectorland talks of two int...原创 2019-05-18 16:59:34 · 571 阅读 · 0 评论 -
Codeforces Round #558 (Div. 2) C1. Power Transmission (Easy Edition)
This problem is same as the next one, but has smaller constraints.It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station(do not tr...原创 2019-05-11 13:58:55 · 573 阅读 · 0 评论 -
Comet OJ - Contest #3 A
N 只小猫站成一排,第 iii 只小猫的实力值是 aia_iai。小猫们要组织一场比赛,对于所有 1≤i<j≤N1 \le i < j \le N1≤i<j≤N,第 iii 只小猫和第jjj只小猫之间可以展开一场精彩度为 ai+aja_i+a_jai+aj 的比赛,这样,总共就能展开 N(N−1)2\frac{N(N-1)}{2}2N(N−1) 场比赛。熊老...原创 2019-05-10 21:20:20 · 172 阅读 · 0 评论 -
Codeforces Round #559 (Div. 2) C. The Party and Sweets(二分)
nnboys andmmgirls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from11tonnand all girls are numbered with in...原创 2019-05-13 18:05:25 · 535 阅读 · 0 评论 -
hdu6709——Fishing Master
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6709思路:先抓煮的时间多的鱼,把煮鱼时间放进优先队列里,每次找剩余煮鱼时间最多的时候的去抓鱼,然后时间减去抓鱼时间,再放到队列里。最后再把队列里的数加起来#include<algorithm>#include<string.h>#include<stdio....原创 2019-08-24 10:55:13 · 291 阅读 · 0 评论 -
Educational Codeforces Round 71 (Rated for Div. 2)——B. Square Filling
题目链接:http://codeforces.com/contest/1207/problem/B思路:因为题目不需要找最少次数,直接枚举x,y。符合条件直接改变。#include<bits/stdc++.h>using namespace std;int n,m,sum;int A[55][55],B[55][55];vector<pair<int,in...原创 2019-08-23 09:52:08 · 170 阅读 · 0 评论 -
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)——C. Magic Grid
题目链接:http://codeforces.com/contest/1208/problem/C思路:1.把n*n的方格分成(n/4)*(n/4)个4*4的小方格 2.保证每个4*4的小方格每行和每列xor值为0 发现如下可以符合2条件 在每个4*4的方格按上述规律填好即可#include...原创 2019-08-26 16:05:53 · 142 阅读 · 0 评论 -
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)——B. Uniqueness
题目链接:http://codeforces.com/contest/1208/problem/B思路:枚举左边可以选的个数,加上右边最大可以选的个数。最后用总个数减去最多可以选的个数就是要删除的数#include<algorithm>#include<string.h>#include<stdio.h>#include<map>u...原创 2019-08-26 14:07:46 · 250 阅读 · 0 评论 -
Codeforces Round #581 (Div. 2)——C. Anna, Svyatoslav and Maps
题目链接:http://codeforces.com/contest/1204/problem/C思路:跑一遍floyd,找出每两个点间的距离 设当前到i点,要到k点,问中间的j点能否删除,使得删除后i到k点的最短路等于i经过j点到k点的路径 能删除的条件:i经过j点到k点的路径要等于i到k点的最短路,也就是没有更短的路径能在不经过j点的情况下到...原创 2019-08-22 16:59:06 · 204 阅读 · 0 评论 -
Codeforces Round #579 (Div. 3)——E. Boxers
题目链接:http://codeforces.com/contest/1203/problem/E思路:能减1就减,不然本身,再不然就加1,还不行就...........#include<bits/stdc++.h>using namespace std;map<int,int>mp;int A[150010];int main(){ int n...原创 2019-08-17 16:39:19 · 222 阅读 · 0 评论 -
Codeforces Round #579 (Div. 3)——D2. Remove the Substring (hard version)
题目链接:http://codeforces.com/contest/1203/problem/D2思路:找出s串中从头开始第一个与t串匹配的子串,找出s串中最后一个与t串匹配的子串。 答案要么删去s串中最后一个满足条件的t串的第一个字符前的序列,或者s串中第一个满足条件的t串的最后一个字符后的序列,或者s中满足条件的t串的两个字符中的序列。#include<...原创 2019-08-17 16:20:18 · 189 阅读 · 0 评论 -
Codeforces Round #579 (Div. 3)——C. Common Divisors
C. Common Divisorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an arrayaaconsisting ofnnintegers.Your tas...原创 2019-08-17 09:35:04 · 267 阅读 · 0 评论 -
Codeforces Round #579 (Div. 3)——B. Equal Rectangles
You are given4n4nsticks, the length of theii-th stick isaiai.You have to creatennrectangles, each rectangle will consist of exactly44sticks from the given set. The rectangle consists of four...原创 2019-08-16 18:09:02 · 169 阅读 · 0 评论 -
Codeforces Round #580 (Div. 2)——Shortest Cycle
题目链接:http://codeforces.com/contest/1206/problem/D思路:1e18不超过2^63,所以当有126的以上个数时,答案为3 小于126直接暴力 0需要删除,因为当126个数以上,当0参入其中时不计入条件,0与任何数都不产生边#include<stdio.h>#include<ma...原创 2019-08-20 17:35:47 · 133 阅读 · 0 评论 -
SCU - 4438——Censor(哈希)
题目链接:http://acm.scu.edu.cn/soj/problem.action?id=4438题意:给出一个串a和串b,串b中如果有a串则删除,删除后b剩下的串再连到一起,再找串a,反复进行,直到不能再删除为止。求最后的串b。思路:把串a的哈希求出,用栈来维护串b。#include<algorithm>#include<string.h>#in...原创 2019-04-24 11:00:25 · 426 阅读 · 0 评论 -
UVALive - 3902 Network
题目链接:https://cn.vjudge.net/problem/16451/origin题意:一个服务器能覆盖k距离的用户点,每个叶子节点都是用户点,初始位置s有一个服务器。数据是一颗树。问最少要多少个点当服务器能覆盖全部用户。 输入:T组数据,n个节点,s,k,n-1行表示边。思路:把已给的服务器点当根,每次从最远未覆盖的叶子节点开始,第k个父亲节点当服务器...原创 2019-05-01 21:05:30 · 346 阅读 · 0 评论 -
UVA - 10881 Piotr's Ants(思维题)
一根长度为L厘米的木棍上有n只蚂蚁,每只蚂蚁要么朝左爬,要么朝右爬,速度为1厘米/秒。当两只蚂蚁相撞时,二者同时掉头(掉头时间忽略不计)。给出每只蚂蚁的初始位置和朝向,计算T秒之后每只蚂蚁的位置。Input输入的第一行为数据组数。每组数据的第一行为3个正整数L,T,n(0<=n<=10000);以下n行每行描述一只蚂蚁的初始位置。其中,整数x为蚂蚁距离左端的距离(单位:厘米),字母表示...原创 2018-07-15 15:53:20 · 245 阅读 · 0 评论 -
nyoj128-前缀式计算
题目描述: 先说明一下什么是中缀式:如2+(3+4)*5这种我们最常见的式子就是中缀式。而把中缀式按运算顺序加上括号就是:(2+((3+4)*5))然后把运算符写到括号前面就是+(2 *( +(3 4) 5) )把括号去掉就是:+ 2 * + 3 4 5最后这个式子就是该表达式的前...原创 2018-07-06 18:01:41 · 129 阅读 · 0 评论 -
nyoj35-表达式求值
题目描述: ACM队的mdd想做一个计算器,但是,他要做的不仅仅是一计算一个A+B的计算器,他想实现随便输入一个表达式都能求出它的值的计算器,现在请你帮助他来实现这个计算器吧。比如输入:“1+2/4=”,程序就输出1.50(结果保留两位小数) ...原创 2018-07-06 13:06:36 · 269 阅读 · 0 评论 -
nyoj467-中缀式变后缀式
题目描述: 人们的日常习惯是把算术表达式写成中缀式,但对于机器来说更“习惯于”后缀式,关于算术表达式的中缀式和后缀式的论述一般的数据结构书都有相关内容可供参看,这里不再赘述,现在你的任务是将中缀式变为后缀式。 ...原创 2018-07-06 11:53:28 · 352 阅读 · 0 评论 -
HDU - 1238——Substrings (查找所有串中最长子串)
You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings.InputTh...原创 2018-05-02 21:34:53 · 724 阅读 · 0 评论 -
沃老师学生的成绩
第一次期中考终于结束啦!沃老师是个语文老师,他在评学生的作文成绩时,给每位学生的分数都是一个小于10的非负小数。沃老师并不会告诉大家分数的排名,但学生间竞争激烈,大家都想知道自己的作文成绩在班上的排名。 但由于作文分数的小数部分可能超级长,难以用肉眼比较两个数的大小关系,请你帮忙写个程序,把所有学生按照作文分数排序吧〜 输入3Amy 8.9999999999999999999999999...原创 2018-04-13 21:37:00 · 314 阅读 · 0 评论 -
HihoCoder - 1721 回文字符串2
愚人节那天,小Ho在小Hi的一个回文字符串中添加了一个字符。你能帮助小Hi找到被添加的是第几个字符吗? Input 一个只包含小写字母的字符串S。 对于70%的数据,|S| ≤ 1000 对于100%的数据,|S| ≤ 500000 ...原创 2018-04-11 21:26:10 · 185 阅读 · 0 评论 -
nyoj451光棍节的快乐
光棍们,今天是光棍节。聪明的NS想到了一个活动来丰富这个光棍节。规则如下:每个光棍在一个纸条上写一个自己心仪女生的名字,然后把这些纸条装进一个盒子里,这些光棍依次抽取一张纸条,如果上面的名字就是自己心仪的女生,那么主持人就在现场给该女生打电话,告诉这个光棍对她的爱慕之情,并让光棍当场表白,并得到现场所有人的祝福,没抽到的,嘿嘿就可以幸免了。假设一共有N个光棍,其中有M个没有抽到自己的纸条,求发生这...原创 2018-04-16 19:32:06 · 338 阅读 · 2 评论 -
CodeForces - 738B
Theater stage is a rectangular field of size n × m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or n...原创 2018-04-11 10:32:59 · 233 阅读 · 0 评论 -
HihoCoder - 1700
在CSS中我们可以用井号(#)加6位十六进制数表示一种颜色,例如#000000是黑色,#ff0000是红色,#ffd700是金色。 同时也可以将六位颜色#RRGGBB简写为#RGB三位颜色。例如#000与#000000是相同的,#f00与#ff0000是相同的,#639与#663399是相同的。 对于两个颜色#abcdef和#ghijkl,我们定...原创 2018-03-31 20:22:43 · 194 阅读 · 0 评论 -
HihoCoder - 1701
给定N个整数A1, A2, ... AN,小Hi希望从中选出M个整数,使得任意两个选出的整数的差都是K的倍数。 请你计算有多少种不同的选法。由于选法可能非常多,你只需要输出对1000000009取模的结果。 Input 第一行包含三个整数N、M和K。 第二行包含N...原创 2018-03-31 19:04:54 · 235 阅读 · 0 评论 -
51Nod - 1005 大数加法
给出2个大整数A,B,计算A+B的结果。Input第1行:大数A第2行:大数B(A,B的长度 <= 10000 需注意:A B有可能为负数)Output输出A + BSample Input68932147586468711654886Sample Output537643802472思路:写出大数加法的函数和大数减法的函数,然后分情况讨论。...原创 2018-08-20 11:18:43 · 255 阅读 · 0 评论 -
ZOJ - 3867——Earthstone: Easy Version
Earthstone is a famous online card game created by Lizard Entertainment. It is a collectible card game that revolves around turn-based matches between two opponents. Players start the game with a subs...原创 2018-10-17 21:51:21 · 150 阅读 · 0 评论 -
CodeForces - 405B——Domino Effect
voj链接:https://cn.vjudge.net/contest/292206#problem/Gcf链接:https://codeforces.com/problemset/problem/405/B题意:多米诺骨牌,L为向左倒,R为向右倒,求有多少张牌是立着的,如果一张牌被左右两边的牌压着,也算立着。思路:从左到右模拟一下,从左到右模拟的时候L不可能影响到还没有模拟到的,在碰...原创 2019-04-03 19:53:41 · 238 阅读 · 0 评论