c++
我就一萌新
We Can Be Both Of God And The Devil,Since We're Trying To RaiseThe Dead,Against The Stream Of Time
展开
-
Codeforces Round #769 (Div. 2)A. ABC
题目链接:A.ABC题目大概意思是:给你个只有0和1的字符串,如果他出现了长度大于1的子串是回文就输出NO,否则YES。思路:如果这个字符串长度大于2肯定是NO,因为2位的时候保证不是回文的前提下只能是01或者10,第三位的时候不管加什么都会出现回文,长度为2位的时候只有00和11是回文输出NO,其他情况都是YES。(总的意思就是字符串出现00,11,101,010就是NO,否则YES)#include "bits/stdc++.h"using namespace std;int ma原创 2022-01-31 15:57:45 · 592 阅读 · 0 评论 -
CodeForces - 811B.Vladik and Complicated Book
题目传送门https://codeforces.com/problemset/problem/811/B题目意思:有串数字,然后再给你一个区间[L,R],将他们中间的数排序即可。然后判断他们中间某一位数字是否发生了变化。思路:把这个区间小于等于x这个数的个数求出来,值会是x-l+1#include <bits/stdc++.h>using namespace std;int s[20000];int main(){ int n,m,l,r,x,gs=0; wh原创 2022-01-25 22:06:44 · 193 阅读 · 0 评论 -
CodeForces 722B. Verse Pattern
题目链接:CodeForces 722B. Verse Pattern题目大意:是给n个字符串,和对应n个数字,要求每个字符串里面的元音字母个数要与对应的数字相等,相等输出YES,否则输出NO思路:把每句的元音字母数量存一下,比较下,如果有一个数量对不上就输出NO就好了#include "bits/stdc++.h"using namespace std;const int N=105;int num[N]={0},vis[N]={0},n;int main(){ string原创 2022-01-25 21:00:54 · 376 阅读 · 0 评论 -
CodeForces 302B Eugeny and Play List
题目大概意思是:给你N首歌曲,然后再给出对应的次数和时间,然后有M次提问,问它再听哪一首歌思路:我们把每首歌的次数和时间都存起来,然后直接暴力 遍历下一就可以了#include"bits/stdc++.h"using namespace std;struct node{ long long cs,time;}sv[100005];long long s[100005];int main(){ int n,m; while(cin>>n>>m原创 2022-01-25 18:01:51 · 743 阅读 · 0 评论 -
牛牛看云C++
这题意思就是文中的那个公式这个公式相当于如果知道这个的话,很多人可能都试过直接暴力,然后就出现了时间超限,然后就不知所措了。我们先不管绝对值和1000时候想想a=1 2 3 4的情况:(1+1)+ (1+2)+ (1+3)+ (1+4)(2+2)+ (2+3)+ (2+4)(3+3)+ (3+4)(4+4)再想想a=1 1 1 1时的情况:(1+1)+(1+1)+(1+1)+(1+1)(1+1)+(1+1)+(1+1)(1+1)+(1+1)(1+1.原创 2022-01-25 14:40:41 · 285 阅读 · 0 评论 -
Codeforces Round #767 (Div. 2) B. GCD Arrays(水题)
题目大致意思,给你一个由[L,R]内的所有整数组成的一个数组,给你最多K次操作有没有办法让gcd最后结果为1#include "bits/stdc++.h"using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); long long t,n,m,d,f=0; cin>>t; while (t--){ cin>>n&g原创 2022-01-23 04:00:00 · 323 阅读 · 0 评论 -
Codeforces Round #767 (Div. 2)A. Download More RAM(水题)
题目意思大概是:给你N个软件和一个现有内存,然后你输入N个软件的运行所需要的内存大小和运行后可以获得的内存大小,求最多可以搞到多少内存#include "bits/stdc++.h"using namespace std;struct node{ int a,b;}s[105];bool cmp(node a,node b){ if(a.a!=b.a)return a.a<b.a; return a.b>b.b;}int main(){ long原创 2022-01-23 04:00:00 · 325 阅读 · 0 评论 -
Codeforces 385B Bear and Strings
题目大致意思:给你一个字符串,让你计算这个字符串里面有多少个子串含有bear。想法:每当找到一个bear,就用这个bear(后面字符的个数+1)*(前面字符的个数+1),当然这样会重复计算,因此要减去上一个bear中的个数。#include<bits/stdc++.h>using namespace std;int main(){ string s; cin>>s; int cd=s.size(),ans=0,zhi=0; for(int原创 2022-01-21 18:36:15 · 334 阅读 · 0 评论 -
Codeforces B. Maxim Buys an Apartment(水题)
题目大概意思是:n间一排的房子,其中k个房子有人,然后你是个强迫症一定要附近有人才有安全感,问你最少和最多有多少个房子满足你的需求#include<bits/stdc++.h>using namespace std;int main(){ long long n,m; cin>>n>>m; if(n==m||m==0){ n=0; m=0; }else if(n>=3*m){原创 2022-01-21 18:21:45 · 106 阅读 · 0 评论 -
CodeForces 934B.A Prosperous Lot (水题)
题意大概意思是:从0-9这10个阿拉伯数字里找圈,比如0,4,6,8,9这五个数都是有圈的,其中8有两个圈,这道题就是输入一个数n,让你输出一个含有n个圈的数,因为题目说10^18,所以最多换18*2,超过全部输出-1#include<bits/stdc++.h>using namespace std;int main(){ int n; cin>>n; if(n>36)cout<<-1<<endl; else{原创 2022-01-21 17:28:47 · 235 阅读 · 0 评论 -
CodeForces 708A. Letters Cyclic Shift(字符串)
题目意思大概是:从仅有小写字母组成的字符串s中挑选出一个非空子串,将该子串中的每个字母均替换成前一个字母,如'b'换成'a','c'换成'b',以此类推,特别的,'a'要换成'z'。问经过一次转换之后,字典序最小的字符串s为多少#include<bits/stdc++.h>using namespace std;int main(){ string s; cin>>s; map<char,char>mp; int k=0;原创 2022-01-21 17:06:28 · 314 阅读 · 0 评论 -
(CodeForces - 1051A)Vasya And Password 模拟,水题
题目大概意思:用最小的改变次数,把字符串,改成有数字,有小写,有大写的样子#include "bits/stdc++.h"using namespace std;int main(){ int n; string s; cin>>n; for(int i=1;i<=n;i++){ int a=0,b=0,c=0; cin>>s; for(int j=0;j<s.size();j+原创 2022-01-21 16:08:01 · 83 阅读 · 0 评论 -
CodeForces - 6C Alice, Bob and Chocolate
题目意思是:放在桌上一层巧克力,女的从左边开吃,男的从右边开吃,每一个巧克力都有吃的时间,如果两个人吃到同一块,女士优先。问男女各吃了多少个巧克力#include<bits/stdc++.h>using namespace std;int s[1000010];int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>s[i]; } int p1=原创 2022-01-20 16:12:24 · 276 阅读 · 0 评论 -
More is better (并查集,离散化)
题目意思大概是说:输入一个N,然后输入N行,每行的一对数是好朋友,他们可以站在一起,最后让求的是每一组中人数的最大值#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int s[100001],x[100001],y[100001];int u[200001],v[200001],vis[200000];原创 2022-01-18 20:16:59 · 178 阅读 · 0 评论 -
Codeforces Round #766 (Div. 2)B.Not Sitting
这题,其实我们把每一个位置都跑一遍,把他和(左上角,左下角,右上角,右下角)取个最大的差值,然后存起来,然后排序下,就是答案了-------------------------------------属实不知道它涂漆什么用代码如下#include "bits/stdc++.h"using namespace std;int main(){ int t,n,m,yi,er,san,si,ans; while (cin>>t){ vector<原创 2022-01-16 10:52:10 · 439 阅读 · 2 评论 -
Codeforces Round #766 (Div. 2)A.Not Shading
该题是问你几步可以把该位置变成黑色,其实就4个情况:第一种,自己就是黑的输出0第二种 自己不是黑,并且地图没有黑输出 -1第三种自己不是黑,但是它该行或者该列有黑输出1剩下都输出2代码如下#include "bits/stdc++.h"using namespace std;char s[55][55];int main(){ int t,n,m,x,y; while (cin>>t){ while (t--){原创 2022-01-16 10:47:33 · 497 阅读 · 0 评论 -
田忌赛马 c++【贪心,模拟】
#include "bits/stdc++.h"using namespace std;int x[1000005];int y[1000005];int main(){ int n; while (cin>>n){ if(n==0)break; for(int i=1;i<=n;i++)cin>>x[i]; for(int i=1;i<=n;i++)cin>>y[i]; .原创 2022-01-06 23:20:13 · 1112 阅读 · 0 评论 -
[ZZULIOJ]1121: 电梯
我们城市最高的建筑只有一部电梯。请求列表由N个正数组成。这些数字按规定的顺序表示电梯将在几层楼停下来。电梯上一层需要6秒,下一层需要4秒。电梯每停一站停留5秒。对于给定的请求列表,您需要计算完成列表上的请求所需的总时间。电梯一开始在第0层,当请求被满足时,它不必返回到第1层。输入有多个测试用例。每种情况包含一个正整数N,后面跟着N个正数。所有输入的数字都小于100。N = 0的测试用例表示输入的结束。不处理这个测试用例。输出将每个测试用例的总时间打印在一行上。样例输.原创 2021-12-17 23:36:52 · 292 阅读 · 0 评论 -
Codeforces Round #761 (Div. 2)A-C
#include<bits/stdc++.h>using namespace std;map<char,int>mp;int main(){ int n; string s,tt,ss; while(cin>>n){ while(n--){ mp.clear(); cin >> s >> tt; ss = ""; ...原创 2021-12-17 21:08:51 · 93 阅读 · 0 评论 -
Codeforces Round #748 (Div. 3)D1. All are Same[暴力]
#include <bits/stdc++.h>using namespace std;typedef long long ll;int s[105],dp[105];int main(){ ll t; cin>>t; while(t--){ int s1,ss,z=0; map<int,int>mp; cin>>s1; for(int i=0;i<...原创 2021-10-14 05:00:00 · 142 阅读 · 0 评论 -
Codeforces Round #748 (Div. 3)B.Make it Divisible by 25[暴力,思维]
#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll t; cin>>t; while(t--){ long long ans=0,anss=0; string s; cin>>s; for(int i=s.size()-1;i>=0;i--){ ...原创 2021-10-14 05:00:00 · 281 阅读 · 0 评论 -
数组元素循环右移问题 (20 分)PTA
一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置,即将A中的数据由(A0A1⋯AN−1)变换为(AN−M⋯AN−1A0A1⋯AN−M−1)(最后M个数循环移至最前面的M个位置)。如果需要考虑程序移动数据的次数尽量少,要如何设计移动的方法?输入格式:每个输入包含一个测试用例,第1行输入N(1≤N≤100)和M(≥0);第2行输入N个整数,之间用空格分隔。输出格式:在一行中输出循环右移M位以后的整数序列,之间用空格分隔,.原创 2021-10-11 14:24:54 · 324 阅读 · 0 评论 -
整除光棍 (20 分)
这里所谓的“光棍”,并不是指单身汪啦~ 说的是全部由1组成的数字,比如1、11、111、1111等。传说任何一个光棍都能被一个不以5结尾的奇数整除。比如,111111就可以被13整除。 现在,你的程序要读入一个整数x,这个整数一定是奇数并且不以5结尾。然后,经过计算,输出两个数字:第一个数字s,表示x乘以s是一个光棍,第二个数字n是这个光棍的位数。这样的解当然不是唯一的,题目要求你输出最小的解。提示:一个显然的办法是逐渐增加光棍的位数,直到可以整除x为止。但难点在于,s可能是个非常大的数 —— 比如,程原创 2021-10-11 14:21:04 · 77 阅读 · 0 评论 -
古风排版 (20 分)PTA[字符串插入之水题]
中国的古人写文字,是从右向左竖向排版的。本题就请你编写程序,把一段文字按古风排版。输入格式:输入在第一行给出一个正整数N(<100),是每一列的字符数。第二行给出一个长度不超过1000的非空字符串,以回车结束。输出格式:按古风格式排版给定的字符串,每列N个字符(除了最后一列可能不足N个)。输入样例:4This is a test case输出样例:asa Tst ihe tsi ce sCODE:#include "bits/stdc++.h".原创 2021-10-11 14:18:14 · 68 阅读 · 0 评论 -
螺旋方阵 (20 分)PTA
所谓“螺旋方阵”,是指对任意给定的N,将1到N×N的数字从左上角第1个格子开始,按顺时针螺旋方向顺序填入N×N的方阵里。本题要求构造这样的螺旋方阵。输入格式:输入在一行中给出一个正整数N(<10)。输出格式:输出N×N的螺旋方阵。每行N个数字,每个数字占3位。输入样例:5输出样例: 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9#include&l.原创 2021-10-11 14:14:14 · 357 阅读 · 0 评论 -
Codeforces Round #744 (Div. 3)C. Ticks【水题】
因为他V左边高度要等于右边- -最后一发A的时候,没加最高条件重判的时候wa了。。。加上就A了呜呜呜time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCasimir has a rectangular piece of paper with a checkered field of sizen×mn×m. Initi.原创 2021-09-29 15:38:18 · 315 阅读 · 0 评论 -
Problem C[hdu5687]字典树
题目描述:度熊手上有一本神奇的字典,你可以在它里面做如下三个操作:1、insert : 往神奇字典中插入一个单词2、delete: 在神奇字典中删除所有前缀等于给定字符串的单词3、search: 查询是否在神奇字典中有一个字符串的前缀等于给定的字符串输入描述:这里仅有一组测试数据。第一行输入一个正整数N (1\leq N\leq 100000)N(1≤N≤100000),代表度熊对于字典的操作次数,接下来NN行,每行包含两个字符串,中间中用空格隔开。第一个字符串代表了相关...原创 2021-09-26 16:41:59 · 87 阅读 · 0 评论 -
HDU1686 Oulipo (KMP模板题)
InputThe first line of the input file contains a single number: the number of test cases to follow. Each test case has the following format:One line with the word W, a string over {'A', 'B', 'C', …, 'Z'}, with 1 ≤ |W| ≤ 10,000 (here |W| denotes the len.原创 2021-09-09 20:53:40 · 71 阅读 · 0 评论 -
Educational Codeforces Round 113 (Rated for Div. 2)A题Balanced Substring
思路找到任意一个位置i,满足s [ i ] ≠ s [ i + 1 ] 那么直接输出[ i , i + 1 ]这个区间作为答案即可如果都没有输出-1 ,-1代码如下:#include "bits/stdc++.h"using namespace std;int main(){ long long n,m;string s; cin>>n; while (n--){ cin>>m>>s; in原创 2021-09-09 19:06:38 · 242 阅读 · 0 评论 -
HDU(2594) KMP
Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah, what is it?Homer: Take me for example. I want to find out if I have a talent in politics, OK?Marge: OK.Homer: So I take some politician’s name,.原创 2021-09-09 19:01:00 · 119 阅读 · 0 评论 -
Codeforces Round #736 (Div. 2)C. Web of Lies
C. Web of LiesThere arennnobles, numbered from11tonn. Nobleiihas a power ofii. There are alsomm"friendships". A friendship between noblesaaandbbis always mutual.A noble is defined to bevulnerableif both of the following conditions are ...原创 2021-09-04 16:01:23 · 135 阅读 · 0 评论 -
Codeforces Beta Round #1 B. Spreadsheets
B. SpreadsheetsIn the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is mar...原创 2021-09-03 13:51:41 · 84 阅读 · 0 评论 -
Codeforces Round #741 (Div. 2)C. Rings(水题)
题目很简单,把二进制思维带进去就ok了#include<bits/stdc++.h>using namespace std;string s;//二进制11是3 110是6//题目要求在 左边的数是右边的倍数//二进制的情况只要在数后面多一个0就是乘以2//只要找到这个字符串0的位置,判断该0位置,在前半部分还是后半部分,如果没0,就全输出俩个长度相同但是位置不同的字符串就可以了//!!!长度一定要大于等于一半int main(){ long long n,原创 2021-08-31 15:51:51 · 87 阅读 · 0 评论 -
hdu1535[优先队列]
关系链先存着,正着跑一边,然后清空,然后关系链反正跑一边,加起来就是答案了- -记得要scanf,不然超时#include "bits/stdc++.h"using namespace std;const int maxx=1e6+5;const int maxn=0x3f3f3f3f;int n,m,v1,u1,w1;int ans[maxx];int vis[maxx];int head[maxx];struct Edge{ int to,next,w;}edge[ma原创 2021-08-20 16:53:00 · 130 阅读 · 1 评论