![](https://img-blog.csdnimg.cn/20190130142549620.jpeg?x-oss-process=image/resize,m_fixed,h_224,w_224)
模拟篇
模拟篇
桑榆207
在最终的结果到来之前,任何肯定会赢之类的话都是虚无缥缈的。
展开
-
LeetCode 5. 最长回文子串 马拉车+输出字符串
思路:利用马拉车算法,求出hwi,代表以i点为中心的回文半径。求出最长回文子串中心节点的位置,然后,从左右两边取字符即可。代码:class Solution {public: static const int maxn=1000+10; int n; int maxx=0; int midc=0; char now[maxn*2]; ...原创 2020-04-15 19:03:59 · 152 阅读 · 0 评论 -
数的划分问题总结 DP或递归
问题 1531: [蓝桥杯][算法提高VIP]数的划分时间限制: 1Sec 内存限制: 128MB 提交: 438 解决: 175题目描述一个正整数可以划分为多个正整数的和,比如n=3时:3;1+2;1+1+1;共有三种划分方法。给出一个正整数,问有多少种划分方法。数据规模和约定n< =100输入一个正整数n输出一个正整数,表示划分方案数样例...原创 2020-02-10 19:51:16 · 162 阅读 · 0 评论 -
蚂蚁感冒 思维
问题 1454: [蓝桥杯][历届试题]蚂蚁感冒时间限制: 1Sec 内存限制: 128MB 提交: 1623 解决: 687题目描述长100厘米的细长直杆子上有n只蚂蚁。它们的头有的朝左,有的朝右。每只蚂蚁都只能沿着杆子向前爬,速度是1厘米/秒。当两只蚂蚁碰面时,它们会同时掉头往相反的方向爬行。这些蚂蚁中,有1只蚂蚁感冒了。并且在和其它蚂蚁碰面时,会把感冒传染给碰到的蚂蚁。请...原创 2020-02-10 12:34:13 · 138 阅读 · 0 评论 -
DFS+BFS问题总结
DFS和BFS问题一、问题 2178: [信息学奥赛一本通-T1255]迷宫问题时间限制: 1Sec 内存限制: 128MB 提交: 9 解决: 5题目描述定义一个二维数组:int maze[5][5] = {0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只...原创 2020-01-31 20:09:58 · 152 阅读 · 0 评论 -
前缀和+差分总结
差分问题总结一维例题:输入一个长度为n的整数序列。接下来输入m个操作,每个操作包含三个整数l, r, c,表示将序列中[l, r]之间的每个数加上c。请你输出进行完所有操作后的序列。设那么求a数组时,就可以利用b数组的前缀和来计算在a2-a4区间内每个数加x,就相当于b2加上2,而b3不变,b4也不变,b5要减去2,也就是在l r区间内加x,那么就b[l...原创 2020-01-30 21:53:48 · 246 阅读 · 0 评论 -
Map统计单词个数
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...原创 2019-02-11 21:35:32 · 260 阅读 · 0 评论 -
牛客 Rinne Loves Math 化简二次根式
链接:https://ac.nowcoder.com/acm/contest/370/J来源:牛客网 题目描述Rinne 刚刚学习了最简二次根式,于是她想用程序实现一个。为了简化问题,在本题中,最简二次根式 a√bab 的定义为:不存在b的一个因子k s.t. ∃x∈N∗,x2=k不存在b的一个因子k s.t. ∃x∈N∗,x2=k即根号下的数字不含平方数因子。举个最简二次根式...原创 2019-02-10 22:40:12 · 370 阅读 · 0 评论 -
牛客 Rinne Loves Study 思维题
链接:https://ac.nowcoder.com/acm/contest/370/C来源:牛客网 Rinne 喜欢使用一种奇怪的方法背单词,现在这些单词被放在了一个 n×mn×m 的格子里。由于背单词是一个令人烦躁的事情,所以她决定每天只背同一行或者同一列的单词。她一共会背 T 次单词,为了方便巩固,她现在想知道:对于每个单词,最后一次背是什么时候呢?她这么可爱当然会算啦!但是她想考...原创 2019-02-10 22:38:56 · 403 阅读 · 0 评论 -
HDU2054 A==B? 情况考虑完全
http://acm.hdu.edu.cn/showproblem.php?pid=2054Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".Inputeach test case contains two numbers A and B. Output...原创 2019-02-09 16:57:20 · 265 阅读 · 0 评论 -
Block Towers 模拟||二分
https://cn.vjudge.net/problem/324408/originStudents in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the student...原创 2019-01-16 21:36:46 · 296 阅读 · 0 评论 -
HDU5536模拟||字典树
http://acm.hdu.edu.cn/showproblem.php?pid=5536 Problem Description John is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large amounts of products, ev...原创 2019-01-15 19:00:48 · 161 阅读 · 0 评论 -
牛客 找一找 找因子对个数
链接:https://ac.nowcoder.com/acm/contest/71/A来源:牛客网 题目描述给定n个正整数,请找出其中有多少个数x满足:在这n个数中存在数y=kx,其中k为大于1的整数输入描述: 第一行输入一个n接下来一行输入n个正整数ai输出描述:输出符合条件个数示例1输入复制51 2 3 4 5输出复制...原创 2019-02-05 17:17:05 · 258 阅读 · 0 评论 -
HDU5573 Binary Tree 二进制+规律
http://acm.hdu.edu.cn/showproblem.php?pid=5573The Old Frog King lives on the root of an infinite tree. According to the law, each node should connect to exactly two nodes on the next level, forming ...原创 2019-01-17 19:42:11 · 162 阅读 · 0 评论 -
Codeforces Round #442 (Div. 2)--B. Nikita and string--前后缀和思维
B. Nikita and stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Nikita found the string containing letters "a" and "...原创 2019-09-03 20:36:31 · 127 阅读 · 0 评论 -
CF--Uniqueness--正难则反思想
B. Uniquenesstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an arraya1,a2,…,ana1,a2,…,an. You can removeat most...原创 2019-08-26 14:58:19 · 321 阅读 · 1 评论 -
HDU--Dice--隐式图搜索
Dice Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2488Accepted Submission(s): 1235 Problem Description There are 2 ...原创 2019-08-29 11:32:49 · 98 阅读 · 0 评论 -
Codeforces Round #565 (Div. 3)--C. Lose it!--思维
C. Lose it!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an arrayaaconsisting ofnnintegers. Eachaiaiis one...原创 2019-09-02 15:28:00 · 178 阅读 · 0 评论 -
Codeforces Round #565 (Div. 3)--D. Recover it!--思维+欧拉筛
D. Recover it!time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAuthors guessed an arrayaaconsisting ofnnintegers; each intege...原创 2019-09-02 18:11:43 · 166 阅读 · 0 评论 -
Codeforces Round #369 (Div. 2)--D. Directed Roads--DFS找环或Tarjan
D. Directed Roadstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder and Chris the Baboon has explored Udayland for qui...原创 2019-10-01 15:38:05 · 131 阅读 · 0 评论 -
Codeforces Beta Round #22 (Div. 2 Only)--C. System Administrator--构造割点为V、边有M条的图
C. System Administratortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBob got a job as a system administrator in X corporation. ...原创 2019-09-24 20:43:52 · 89 阅读 · 0 评论 -
牛客挑战赛32--C斐波那契数列卷积 推公式+矩阵快速幂+逆元
链接:https://ac.nowcoder.com/acm/contest/1087/C来源:牛客网斐波那契数列卷积时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述已知数列an=∑k=0nFn−k×Fka_n=\sum_{k=0}^{n}F_{n-k} \times...原创 2019-09-21 09:56:10 · 210 阅读 · 0 评论 -
牛客挑战赛32--B114514 因数分解找规律
链接:https://ac.nowcoder.com/acm/contest/1087/B来源:牛客网114514时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述给你一个长为n的序列定义一个序列下标的子集为先辈,当且仅当选出的这些下标对应的序列值的乘积为114514,...原创 2019-09-21 09:53:43 · 2236 阅读 · 0 评论 -
Codeforces Round #443 (Div. 2)--D. Teams Formation--思维
D. Teams Formationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis time the Berland Team Olympiad in Informatics is held in ...原创 2019-09-10 18:32:51 · 116 阅读 · 0 评论 -
Codeforces Round #443 (Div. 2)--C. Short Program--思维+位运算
C. Short Programtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya learned a new programming language CALPAS. A program in th...原创 2019-09-10 12:09:41 · 118 阅读 · 0 评论 -
O(N)找到第k小的数
#include <bits/stdc++.h>#define ll long longusing namespace std;#define rep(i,a,b) for(register int i=(a);i<=(b);i++)#define dep(i,a,b) for(register int i=(a);i>=(b);i--)//priority_q...原创 2019-09-09 15:14:14 · 178 阅读 · 0 评论 -
Educational Codeforces Round 72 (Rated for Div. 2)--B. Zmei Gorynich--思维
B. Zmei Gorynichtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are fighting with Zmei Gorynich — a ferocious monster from Sl...原创 2019-09-06 16:38:27 · 181 阅读 · 0 评论 -
Codeforces Round #442 (Div. 2)--C. Slava and tanks--思维
C. Slava and tankstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSlava plays his favorite game "Peace Lightning". Now he is fly...原创 2019-09-03 20:31:40 · 177 阅读 · 0 评论 -
Codeforces Round #583 --E. Petya and Construction Set--树上构造
E. Petya and Construction Settime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputIt's Petya's birthday party and his friends have pre...原创 2019-09-05 20:03:56 · 291 阅读 · 0 评论