训练报告
霞鹜
这个作者很懒,什么都没留下…
展开
-
蓝桥杯知识总结(自我复习用)
结构题sort排序,cmp常用于排序倒序的处理struct node { int sum, a, b;}s[2102100];bool cmp(node x, node y) { if (x.sum != y.sum) { return x.sum < y.sum; } if (x.a != y.a) { return x.a < y.a; } return x.b < y.b;}前者是>=x的模板,后者=<x的模板bool check(int原创 2022-04-08 16:54:46 · 823 阅读 · 0 评论 -
天梯赛L1常用知识(自我复习使用)
欧几里得求约数int gcd(int a, int b){ return b ? gcd(b, a%b) : a;}初始化数组或字符串memset(a, 0, sizeof(a));素数筛bool judge(int n){ if(n<2) { return false; } for(int i=2;i<=sqrt(n);i++) if(n%i==0) { return fal原创 2022-03-20 19:26:15 · 537 阅读 · 0 评论 -
线性表的应用——约瑟夫环
#include<iostream>using namespace std;struct AP{ int m; int next; int last;};class Joeph{public: Joeph(); void Joephstart(int); int Joephjudge(); void Joephshow();private: AP people[100]; int n; int first; int number; int count;.原创 2021-10-21 20:59:01 · 186 阅读 · 0 评论 -
蓝桥杯——美丽的2
就是一个暴力找数的题,通过不断历遍完成一个数中是否有2的查找。#include<iostream>using namespace std;int main(){ int ans = 0; for (int i = 1; i <= 2020; i++) { int temp = i; while (temp / 10) { int judge = temp - temp / 10 * 10; if (judge == 2) { ans++; .原创 2021-06-04 09:28:35 · 610 阅读 · 0 评论 -
cf-——ABBB
Zookeeper is playing a game. In this game, Zookeeper must use bombs to bomb a string that consists of letters ‘A’ and ‘B’. He can use bombs to bomb a substring which is either “AB” or “BB”. When he bombs such a substring, the substring gets deleted from th原创 2021-06-03 20:35:55 · 234 阅读 · 0 评论 -
cf——TMT Document
The student council has a shared document file. Every day, some members of the student council write the sequence TMT (short for Towa Maji Tenshi) in it.However, one day, the members somehow entered the sequence into the document at the same time, creatin原创 2021-06-03 20:09:24 · 313 阅读 · 0 评论 -
Sifid and Strange Subsequences
A sequence (b1,b2,…,bk) is called strange, if the absolute difference between any pair of its elements is greater than or equal to the maximum element in the sequence. Formally speaking, it’s strange if for every pair (i,j) with 1≤i<j≤k, we have |ai−aj|原创 2021-05-26 09:13:06 · 194 阅读 · 0 评论 -
Codeforces Round #722 (Div. 2)——A. Eshag Loves Big Arrays
Eshag has an array a consisting of n integers.Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly larger than AVG, where AVG is the average of the numbers in the ch原创 2021-05-25 14:24:19 · 244 阅读 · 0 评论 -
[蓝桥杯2019初赛]数的分解
把2019分解成3个各不相同的正整数之和,并且要求每个正整数都不包含数字2和4,一共有多少种不同的分解方法?注意交换3个整数的顺序被视为同一种方法,例如1000+1001+18 和1001+1000+18 被视为同一种。这个题就是暴力处理,比较核心的就是找每个数字中有没有2,4.#include<iostream>using namespace std;bool judge(int n){ int flag = 1; while (n) { int temp = n - n原创 2021-04-11 20:32:27 · 288 阅读 · 0 评论 -
[蓝桥杯2019初赛]年号字串
小明用字母A 对应数字1,B 对应2,以此类推,用Z 对应26。对于27以上的数字小明用两位或更长位的字符串来对应,例如AA 对应27,AB 对应28,AZ 对应52,LQ 对应329。请问2019 对应的字符串是什么?#include<iostream>using namespace std;const int N = 10;char a[N];int solve(int n){ int temp=n; for (int i = 0;; i++) { int coun原创 2021-04-11 16:43:37 · 655 阅读 · 0 评论 -
[蓝桥杯2019初赛]平方和
小明对数位中含有2、0、1、9 的数字很感兴趣,在1 到40 中这样的数包括1、2、9、10 至32、39 和40,共28 个,他们的和是574,平方和是14362。注意,平方和是指将每个数分别平方后求和。请问,在1 到2019 中,所有这样的数的平方和是多少?这个题是常见的找数字的模板,就是利用%完成对每一位数字的检索,然后完成。#include<iostream>using namespace std;typedef long long ll;int main(){ ll原创 2021-04-10 21:08:31 · 235 阅读 · 0 评论 -
n皇后问题
n-皇后问题是指将 n 个皇后放在 n∗n 的国际象棋棋盘上,使得皇后不能相互攻击到,即任意两个皇后都不能处于同一行、同一列或同一斜线上。现在给定整数n,请你输出所有的满足条件的棋子摆法。输入格式共一行,包含整数n。输出格式每个解决方案占n行,每行输出一个长度为n的字符串,用来表示完整的棋盘状态。其中”.”表示某一个位置的方格状态为空,”Q”表示某一个位置的方格上摆着皇后。每个方案输出完成后,输出一个空行。数据范围1≤n≤9样例输入样例:4输出样例:.Q……QQ……Q.…原创 2021-04-10 19:04:58 · 1003 阅读 · 0 评论 -
Saruman‘s Army
一个游戏:在一条直线上有N个糖果。第i个糖果的位置是X[i]。从这N个糖果中选择若干个,把他们标记起来。对于每一个糖果,在和它本身相距为R的区域内必须要有标记的糖果(本身带有标记的糖果,就可以认为和它相距为0的地方有一个糖果被标记)。在满足这个条件的情况,最后如果有a个糖果被标记,编写程序使a最小化。Input输入的测试文件将包含多个样例。 每个测试样例第一行有两个数据,整数R(其中0≤R≤1000)和整数N(其中1≤N≤1000)。 下一行包含N个整数,指示每个糖果的位置X[1],…,X[N](其中0原创 2021-04-08 20:54:58 · 132 阅读 · 0 评论 -
Dominant Piranha
There are n piranhas with sizes a1,a2,…,an in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.Scientists of the Berland State University want to find if there is dominant piranha in the aquarium. The piranha is ca原创 2020-12-16 15:19:24 · 320 阅读 · 0 评论 -
Yet Another Bookshelf
这个题其实本质上并不难,关键我是真的不会历遍,这个题的大致思维是找到第一个一和最后一个一之间0的个数。但是历遍的方式多种多样。第一种我想的是从头历遍一次,碰到第一个1停止;再从尾历遍一次,碰到最后一个1停止,然后再查询其中有多少个0;结果——超时;第二种我想的是从头历遍的同时进行判断,保留第一个1和最后一个1的位置,再查询其中有多少的0;结果——超时;最终我还是想到了不超时的方法,不断计算两个1之间的0,这样就可以计算出了0的个数。代码如下:#include<stdio.h>in原创 2020-12-15 11:05:13 · 131 阅读 · 0 评论 -
12月比赛思维题汇总
这篇博客汇总了我在12月比赛中错误的思维题,出于他们没有固定的分类,将他们进行了汇总。第一题蒲煜凡学长最近学习了素数的许多性质,于是他养成了一种怪癖,只会选择素数,对合数视而不见自从他在CCPC省赛中获得金牌后,就一直答应要带ACM算法协会的成员聚餐,这一天终于到来了!他带领着所有成员来到了学校的餐厅,正当所有人准备点菜的时候,他大喝一声:只能选择价格为质数的菜肴!作为ACM算法协会未来的成员,现在请你来计算一下,蒲煜凡学长一共有多少种点菜策略呢众所周知,由于蒲煜凡学长特别抠门,所以如果看到价格原创 2020-12-13 16:11:17 · 338 阅读 · 1 评论