随笔分类 - 基本算法-模拟
摘要:n个点(n include include include include include include include include include include include include include include include include include define m
阅读全文
摘要:``` The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and
阅读全文
摘要:A sequence a1,a2,…,an is called good if, for each element ai, there exists an element aj (i≠j) such that ai+aj is a power of two (that is, 2d for some
阅读全文
摘要:You are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a
阅读全文
摘要:Little girl Tanya climbs the stairs inside a multi storey building. Every time Tanya climbs a stairway, she starts counting steps from 1 to the number
阅读全文
摘要:Maxim wants to buy some games at the local game shop. There are n games in the shop, the i th game costs ci. Maxim has a wallet which can be represent
阅读全文
摘要:Shuffle'm Up Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14471 Accepted: 6633 Description A common pastime for poker players at a poker
阅读全文
摘要:Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 82431 Accepted: 25319 Description During his last sabbatical, professor M. A.
阅读全文
摘要:"CF" 【题意】:圆形球场有n个门,Allen想要进去看比赛。Allen采取以下方案进入球场:开始Allen站在第一个门,如果当前门前面有人Allen会花费单位时间走到下一个门,如果没人Allen从这个门就进去了。球场的每个门,每单位时间可以进去一个人。问Allen最终是从哪个门进入球场的? 【分
阅读全文
摘要:【链接】: "CF" 【代码】: include define PI acos( 1.0) define pb push_back define F first define S second define debug puts define setp cout n) { string s; cin
阅读全文
摘要:【链接】: "CF/4892" 【题意】: 一个人解决n个问题,这个问题的值比k小, 每次只能解决最左边的或者最右边的问题 解决了就消失了。问这个人能解决多少个问题。 【代码】: include define PI acos( 1.0) define pb push_back define F fi
阅读全文
摘要:【链接】: "CF" 【题意】: 给出n个字符串,保证只包含'('和')',求从中取2个字符串链接后形成正确的括号序列的方案数(每个串都可以重复使用)(像'()()'和'(())'这样的都是合法的,像')('和'('这样的是不合法的) 输入: 第一行一个整数n 第二行到第n+1行每行一个字符串 输出
阅读全文
摘要:【链接】: "CF" 【题意】:对任意一个数a[i] ,可以对任意 满足 i != j 且 a[i] a[j] && a[i] include include include include include include include include include include includ
阅读全文
摘要:【链接】: "CF" 【题意】:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价。 【分析】:分情况讨论,自己多举几个栗子。 【代码】: include include include include include include include include inc
阅读全文
摘要:【链接】: "A" 【题意】:给你n个数的序列和k。判断是否可以三个数组成k(同一个数可以拿多次) 【分析】:每个数vis记录一下。2层循环。两数之和不超过k以及剩下的数出现在序列中那么ok。 【代码】: include define ll long long define pb push_back
阅读全文
摘要:【链接】: "A" 【分析】:可以设置方向数组和标记数组。当不合法(越界/访问过)就转向,转向可以用now=(now+1)%4 【代码】: include define ll long long define pb push_back define inf 0x3f3f3f3f define pll
阅读全文
摘要:"CF978B File Name" 【分析】:设置计数器cnt,计数x的个数;遇到非x,若cnt =3的话累加多出的个数,计数器清零;若最后cnt =3说明没遇到非x无法清零,那后部分就都是x,输出ans+=cnt 2 【代码】: include using namespace std; cons
阅读全文
摘要:【链接】: "CF978A" 【分析】:逆向思考+标记数组去重 【代码】:
阅读全文
摘要:【链接】 "CF985B" 【题意】:给n盏灯,m个开关,每次按开关只能将灯从灯灭的状态转变为灯亮,问是否存在 不按所有开关 就将所有灯打开的方法。 【分析】:有两种办法,一种代码复杂点,容易想到枚举去掉每一行,看看能不能有一行去掉后保证其他的每一列至少有一个1,注意如果去掉某行后有一列为0则这一行
阅读全文
摘要:【链接】: "CF985A" 【题意】:给你n和n/2个数ai,每个ai和奇数、偶数比较距离(注意选了奇数,偶数的距离就不要算了,反之同理),求最小的答案。 【代码】: include include include include using namespace std; define N 100
阅读全文