思维
。。。
Griplan
这个作者很懒,什么都没留下…
展开
-
codeforces 1513A - Array and Peaks 题解
题面题意:输入n,k,要求构造一个序列,使1-n这些数字都出现且仅出现一次,而且满足有k个峰,(中间数大于两边的数就是峰,Ax>Ax+1&&Ax>Ax-1)思路:初始化数组a[n] a[i]=i,保证1-n出现,如果n是偶数,那么最多有n/2-1个峰,奇数有n/2个峰,k>最大峰,直接输出-1,否则就输出序列。序列的输出:每次从取最后一个数(也是最大的数,用sort保证),插到前面两个小的数字中间举例:n=5 k=2MaxPeeks=n/2=2<=k原创 2021-04-15 10:02:07 · 249 阅读 · 1 评论 -
蓝桥杯省赛模拟第三期 E
题目描述思路进制问题,用数组模拟,再逆序输出就行,具体在下面解释代码#include <iostream>using namespace std;int a[26];void check(){ for (int i = 0; i < 26; i++) { if (a[i] >= 26) { a[i + 1] += a[i] / 26; a[i] = a[i] % 26;原创 2021-03-27 15:35:48 · 175 阅读 · 0 评论 -
Codeforces Round #694 (Div. 2) B. Strange List
题面:样例输入输出:思路:最早写题思路就有问题,只是想着单纯模拟一遍,时间超限,再用vector试试发现内存超限,想想也合理,不停的往后添加新元素的话,爆炸式增长,太菜了早就该重新想的。正确思路是用2个数组,一个操作,另一个保留数据,因为a[i]分裂成x个a[i]/x的话,最后总和还是a[i],所以只需要不停改原数组(修改完后,一个修改后的项就代表所有分裂的子项,代表能行的话,所有子项都行,所以直接加上保留数组就好),加上保留数组就好。ac代码#include <bits/stdc++.h原创 2021-01-07 17:25:33 · 167 阅读 · 0 评论 -
CF round#686 补题 C D
晕,昨天一直不在状态,写的迷迷糊糊,div3写成这样。。还是太菜了B - Unique Bid Auction原创 2020-11-26 18:17:55 · 103 阅读 · 0 评论 -
C - K-Complete Word CodeForces - 1332C
题意n个字符的字符串s,判断1总体是不是回文,2每个k长度内是不是周期性的,如果不是,需要改动多少个字符使之能满足思路总体回文,所以第一个周期和最后一个周期肯定回文,而又是周期性的,所以第一个周期正向和最后一个周期也相等,要想做到两点,只能是每一个周期内都回文,所以问题转换成如何找到一个满足回文的小周期,然后把所有周期都按照这个周期改动,定义ans记录改动次数。如何找到最优小周期呢:记录每个周期同一个位置出现次数最多的字符,出现次数最多说明需要改动的字符串最少,具体看代码注释#include<原创 2020-10-31 10:10:36 · 198 阅读 · 1 评论 -
B - Composite Coloring CodeForces - 1332B
题意t组示例,对每一组来说,输入n个合数,给这n个数上m种色(保证m<=11),规则是1每一种颜色必须至少对应一个数字,就是说找最小的m种颜色。2每个数字只能被上一种颜色3如果两个数字最大公约数大于1,这两个可以上同一个颜色。思路1000以内的数字,根号一下最大的也就31,正好是第11个质数,所以能搞...原创 2020-10-29 18:12:20 · 95 阅读 · 0 评论 -
E-Game_2020牛客暑期多校训练 第十场 E 前缀和
题目:There are n columns of blocks standing in a row. The i-th column has ai blocks in the beginning. Each block has size 1\times 1\times 11×1×1. Define (x,y) represent the block at column x and is the y-th block from bottom to top. You can perform one oper原创 2020-08-12 16:18:10 · 153 阅读 · 0 评论 -
Wannafly挑战赛1 A.Treepath
题目描述给定一棵n个点的树,问其中有多少条长度为偶数的路径。路径的长度为经过的边的条数。x到y与y到x被视为同一条路径。路径的起点与终点不能相同。输入描述:第一行一个数n表示点的个数;接下来n-1行,每行两个整数x,y表示边;保证输入数据形成一棵树;1<=n<=100000输出描述:一行一个整数表示答案。#include<bits/stdc++.h>using namespace std;const int N = 100005;int num[2],vis[原创 2020-08-12 16:02:10 · 103 阅读 · 0 评论 -
牛客暑期多校训练营(第七场) B Mask Allocation 补题
题目:Nowadays, the Kingdom of Dreamgrid is suffering from a national pandemic. Fortunately, president Baobao is working effectively with the Center for Disease Control (CDC) and they are trying their best to make everything under control.President Baobao h原创 2020-08-02 21:22:38 · 109 阅读 · 0 评论 -
CodeForces - 1084A The Fair Nut and Elevator 数学
题目The Fair Nut lives in n story house. ai people live on the i-th floor of the house. Every person uses elevator twice a day: to get from the floor where he/she lives to the ground (first) floor and ...原创 2020-05-07 20:32:50 · 126 阅读 · 0 评论 -
Kvass and the Fair Nut CodeForces - 1084B数学
题目The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are vi liters of kvass in the i-th keg. Each keg has a lever. You can pour your glass by exactly 1 l...原创 2020-05-07 20:26:19 · 139 阅读 · 0 评论 -
codeforses Contest for Robots 1321A
A. Contest for Robotstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is preparing the first programming contest for robots. There are...原创 2020-03-05 00:40:55 · 230 阅读 · 0 评论 -
Remove Adjacent codeforses 1321C
C. Remove Adjacenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string ss consisting of lowercase Latin letters. Let the le...原创 2020-03-05 00:21:09 · 100 阅读 · 0 评论 -
Filling Shapes
You have a given integer nn. Find the number of ways to fill all 3×n3×n tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap.This pic...原创 2020-01-08 17:32:38 · 261 阅读 · 0 评论 -
骨牌铺方格
在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数.例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图:Input输入数据由多行组成,每行包含一个整数n,表示该测试实例的长方形方格的规格是2×n (0<n<=50)。Output对于每个测试实例,请输出铺放方案的总数,每个实例的输出占一行。Sample Input132S...原创 2020-01-08 17:23:39 · 452 阅读 · 0 评论 -
AC ME
题目:Ignatius is doing his homework now. The teacher gives him some articles and asks him to tell how many times each letter appears.It’s really easy, isn’t it? So come on and AC ME.输入Each article c...原创 2020-01-08 17:18:23 · 98 阅读 · 0 评论