
水题
csu_xiji
这个作者很懒,什么都没留下…
展开
-
力扣 59. 螺旋矩阵 II 模拟 水
https://leetcode-cn.com/problems/spiral-matrix-ii/思路:昨天代码改一下就完事了。class Solution {public: vector<vector<int>> generateMatrix(int n) { vector<vector<int>> ans(n,vector<int>(n)); int left=0,right=n-1,top=0原创 2021-03-16 16:25:41 · 120 阅读 · 0 评论 -
力扣 304. 二维区域和检索 - 矩阵不可变 二维前缀和
https://leetcode-cn.com/problems/range-sum-query-2d-immutable/思路:二维前缀和,查询时可以把区域划分为四块,O(nm)O(nm)O(nm)初始化,O(1)O(1)O(1)查询。class NumMatrix {public: vector<vector<int>> sum; NumMatrix(vector<vector<int>>& matrix) {原创 2021-03-02 14:23:10 · 212 阅读 · 0 评论 -
力扣 832. 翻转图像 水
https://leetcode-cn.com/problems/flipping-an-image/思路:无聊的每日一题……class Solution {public: vector<vector<int>> flipAndInvertImage(vector<vector<int>>& A) { int n=A.size(),m=A[0].size(),l,r,tmp; for(int i=0;i&原创 2021-02-24 18:17:28 · 121 阅读 · 0 评论 -
力扣 1423. 可获得的最大点数 滑动窗口
https://leetcode-cn.com/problems/maximum-points-you-can-obtain-from-cards/思路:很显然最多有k+1k+1k+1种取法,那么直接枚举就好了。class Solution {public: int maxScore(vector<int>& cardPoints, int k) { int n=cardPoints.size(); int sum=0; f原创 2021-02-06 14:31:19 · 113 阅读 · 0 评论 -
力扣 724. 寻找数组的中心索引 前缀和
https://leetcode-cn.com/problems/find-pivot-index/思路:枚举中间位置iii,看[0,i)[0,i)[0,i)和(i,n)(i,n)(i,n)元素之和是否相等即可,通过前缀和降低复杂度。class Solution {public: int pivotIndex(vector<int>& nums) { int sum=0,lsum=0,n=nums.size(); for(int i=0;i原创 2021-01-28 12:06:39 · 109 阅读 · 0 评论 -
牛客练习赛61 A 打怪
https://ac.nowcoder.com/acm/contest/5026/A思路:计算出打一只怪所消耗的血量,那么就可以直接算出答案了。特判掉一些特殊情况即可。#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;typedef long long ll;int main(){ ...原创 2020-04-11 11:35:24 · 285 阅读 · 0 评论 -
codeforces 1332B Composite Coloring 水 贪心
https://vjudge.net/problem/CodeForces-1332B题目大意:给nnn个数,保证4<=ai<=10004<=a_i<=10004<=ai<=1000,且每个数都不是质数。你需要给这些数染色,保证每个数仅被染色一次,且如果两个数被染成了相同的颜色,那么必须保证它们的gcd>1gcd>1gcd>1。你需要输出...原创 2020-04-01 17:42:18 · 494 阅读 · 0 评论 -
codeforces 1332A Exercising Walk 水
https://vjudge.net/problem/CodeForces-1332A题目大意:给出初始位置x、yx、yx、y,限制位置x1、y1、x2、y2x_1、y_1、x_2、y_2x1、y1、x2、y2,四个数a、b、c、da、b、c、da、b、c、d,表示向左、向右、向下、向上走的步数,你可以任意安排行走的顺序,问能否保证整个过程中x1<=x<=x2,y1<...原创 2020-04-01 17:27:33 · 327 阅读 · 0 评论 -
codeforces 1328B K-th Beautiful String 规律 水题
https://vjudge.net/problem/CodeForces-1328B题目大意:一个长度为nnn的字符串,两个字符为bbb,其余的字符均为aaa,那么满足题意的不同的字符串有n∗(n−1)/2n*(n-1)/2n∗(n−1)/2种,现在给定kkk,求字典序第kkk大的字符串。思路:字典序越小肯定bbb越靠后,比如最小的肯定是a…bba…bba…bb,下一步把第一个bbb前移一...原创 2020-03-28 00:12:32 · 416 阅读 · 0 评论 -
codeforces 1328A Divisibility Problem 水
https://vjudge.net/problem/CodeForces-1328A题目大意:给两个数a、ba、ba、b,每次操作可自增aaa,问最少经过多少次操作可以使得a%b=0a\%b=0a%b=0。思路:究极水题啊,看错题了居然卡了半天,绝了。#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace ...原创 2020-03-28 00:01:00 · 385 阅读 · 0 评论 -
codeforces 1327B Princesses and Princes 水
题目大意:给出nnn个公主的心仪对象,对象的编号按照升序给出,现在国王从第111个公主开始依次配对,每次都会在公主的心仪对象中选择序号最小的且之前从未被选择过的那个,如果找不到就跳过继续为下个公主配对。现在你有一次机会,可以在某位公主的心仪对象列表中再添加111个,问能否使得配对总数增加,如果可以输出这位公主的编号以及添加的编号。思路:阅读理解题?感觉很水。依次处理就好了,最后判断一下配对...原创 2020-03-24 20:30:28 · 258 阅读 · 0 评论 -
codeforces 1327A Sum of Odd Integers 水
https://vjudge.net/problem/CodeForces-1327A题目大意:判断nnn能否由kkk个不同的正奇数的和表示。思路:最小的kkk个不同的正奇数的和等于k2k^2k2(等差数列,可以自己算一下)。那么n<k2n<k^2n<k2时肯定是无解的,否则判断n−k2n-k^2n−k2是否是一个偶数,因为奇数只能转化成奇数,所以差值必须是个偶数。#inc...原创 2020-03-24 20:23:24 · 302 阅读 · 0 评论 -
codeforces 1304A Two Rabbits 水
https://vjudge.net/problem/CodeForces-1304A#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;typedef long long ll;int main(){ int t,x,y,a,b; scanf("%d",&t); ...原创 2020-03-14 18:37:52 · 301 阅读 · 0 评论 -
codeforces 1294A Collecting Coins 水题
https://vjudge.net/problem/CodeForces-1294A题目大意:三个人分别由a、b、ca、b、ca、b、c枚硬币,现在你有nnn枚硬币,你要把这nnn枚硬币分给另外三个人,使得三个人拥有的硬币数量都相等。如果可以做到的话请输出YESYESYES,否则输出NONONO。思路:硬币的总和必须是333的倍数,且平均数必须>=>=>=其他人的硬币数量...原创 2020-03-12 12:27:37 · 270 阅读 · 0 评论 -
codeforces 1301A Three Strings 水
https://vjudge.net/problem/CodeForces-1301A题目大意:给三个字符串a、b、ca、b、ca、b、c,对每个iii,要么交换a[i]、c[i]a[i]、c[i]a[i]、c[i],要么交换b[i]、c[i]b[i]、c[i]b[i]、c[i],问最终能否使得a=ba=ba=b。#include<bits/stdc++.h>#define I...原创 2020-02-14 15:50:48 · 261 阅读 · 0 评论 -
codeforces 1303A Erasing Zeroes 水
https://vjudge.net/problem/CodeForces-1303A题目大意:给一个010101串,最最少删去多少个000可以使所有的111连在一起。#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;typedef long long ll;char s[105];int...原创 2020-02-13 13:43:14 · 279 阅读 · 0 评论 -
codeforces 1300A Non-zero 水题
https://vjudge.net/problem/CodeForces-1300A题目大意:给一个有nnn个元素的数组aaa,每次操作可使ai=ai+1a_i=a_i+1ai=ai+1,问最少经过多少次操作可是使∑ai !=0\sum a_i\ !=0∑ai !=0且a1∗……∗an !=0a_1*……*a_n\ !=0a1∗……∗an !...原创 2020-02-11 11:18:44 · 388 阅读 · 0 评论 -
codeoforces 1250F Data Center 水题
http://codeforces.com/problemset/problem/1250/FYou are developing a project to build a new data center. The data center will be a rectangle with an area of exactly n square meters. Each side of the d...原创 2019-11-03 14:00:03 · 311 阅读 · 0 评论 -
HDU 6264 Super-palindrome(CCPC2017杭州) 水题
http://acm.hdu.edu.cn/showproblem.php?pid=6264题目大意:给定字符串TTT,使得该字符串的每个长度为奇数的子串都是回文串,求至少要修改的字符的数量。思路:水题,容易推得:奇数位置的字符都一样,偶数位置的字符都一样。#include<iostream>#include<cstdio>#include<cstring&...原创 2019-10-20 15:48:34 · 196 阅读 · 0 评论 -
2019亚洲区域赛徐州网络赛 C Buy Watermelon
https://nanti.jisuanke.com/t/41385The hot summer came so quickly that Xiaoming and Xiaohong decided to buy a big and sweet watermelon. But they are two very strange people. They are even-numbered ent...原创 2019-09-07 18:35:03 · 381 阅读 · 0 评论 -
ccpc 2050 B 时间间隔
Problem Description2019年1月1日,在云栖出现了可能是全世界最长的以秒为单位的倒计时装置:九亿多秒倒计时,直到2050年。给出一个时间S,我们想知道S距离2050年1月1日0点0时0分多少秒。因为答案可能很大,请输出答案模100的值。Input第一行一个正整数 T(1≤T≤100000) 表示数据组数。对于每组数据,一行一个字符串表示时间。时间...原创 2019-04-14 11:02:43 · 185 阅读 · 0 评论 -
HDU 2005 第几天 模拟 水
http://acm.hdu.edu.cn/showproblem.php?pid=2005给定一个日期,输出这个日期是该年的第几天。Input输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。Output对于每组输入数据,输出一行,表示该日期是该年的第几天。Sample Input...原创 2019-01-27 22:15:56 · 102 阅读 · 0 评论 -
codeforces 1199 B Water Lily 水题
http://codeforces.com/problemset/problem/1199/B添加链接描述思路:x+H=y,x2+L2=y2x+H=y,x^{2}+L^{2}=y^{2}x+H=y,x2+L2=y2。#include<iostream>#include<cstdio>#include<algorithm>#include<vec...原创 2019-08-31 10:52:53 · 388 阅读 · 0 评论 -
codeforces 1199A City Day 水题
http://codeforces.com/problemset/problem/1199/AFor years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the c...原创 2019-08-31 10:47:46 · 248 阅读 · 0 评论 -
CodeForces 1152B Neko Performs Cat Furrier Transform
链接:http://codeforces.com/problemset/problem/1152/BCat Furrier Transform is a popular algorithm among cat programmers to create longcats. As one of the greatest cat programmers ever exist, Neko wants...原创 2019-07-22 09:00:35 · 205 阅读 · 0 评论 -
Codeforces 1132 A 思维 水题
http://codeforces.com/contest/1132/problem/AA string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possibl...原创 2019-03-08 00:07:09 · 463 阅读 · 0 评论 -
HDU 2051 进制转换
http://acm.hdu.edu.cn/showproblem.php?pid=2051妙妙学姐最近迷上了二进制,但她不会转换二进制,于是她就拿着她收藏的数字来找你啦,你能帮助妙妙学姐把她的十进制数字转换二进制吗?Input多组测试数据,请处理到EOF。每行一个正整数n(0<n<1000),表示妙妙学姐的数字。Output对每个数字在一行输出对应的二进制。...原创 2019-03-03 14:59:38 · 187 阅读 · 0 评论 -
CodeForces 1121A 排序 水
http://codeforces.com/problemset/problem/1121/AEverybody knows that the m -coder Tournament will happen soon. mm schools participate in the tournament, and only one student from each school particip...原创 2019-03-05 00:31:25 · 385 阅读 · 0 评论 -
洛谷 P1739 表达式括号匹配 栈
https://www.luogu.org/problemnew/show/P1739题目描述假设一个表达式有英文字母(小写)、运算符(+,—,*,/)和左右小(圆)括号构成,以“@”作为表达式的结束符。请编写一个程序检查表达式中的左右圆括号是否匹配,若匹配,则返回“YES”;否则返回“NO”。表达式长度小于255,左圆括号少于20个。输入输出格式输入格式: 一行:表达式...原创 2019-02-17 16:53:17 · 499 阅读 · 0 评论 -
HDU 2021 发工资喽 基础贪心 水
http://acm.hdu.edu.cn/showproblem.php?pid=2021作为杭电的老师,最盼望的日子就是每月的8号了,因为这一天是发工资的日子,养家糊口就靠它了,呵呵但是对于学校财务处的工作人员来说,这一天则是很忙碌的一天,财务处的小胡老师最近就在考虑一个问题:如果每个老师的工资额都知道,最少需要准备多少张人民币,才能在给每位老师发工资的时候都不用老师找零呢?这里假设老...原创 2019-01-27 00:00:44 · 175 阅读 · 0 评论 -
HDU 2028 计算n个数的最小公倍数
http://acm.hdu.edu.cn/showproblem.php?pid=2028求n个数的最小公倍数。Input输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数。Output为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行。你可以假设最后的输出是一个32位的整数。Sample Input2 4 63 2 5 7Sa...原创 2019-01-27 00:00:50 · 187 阅读 · 0 评论 -
求n个数的最小公倍数
JJery学长刚刚结束了计算两个数的最小公倍数的问题,又想转型计算复杂一些的问题,JJery学长在想,如果有n个数,我应该怎么求他的最小公倍数呢?JJery学长冥思苦想,终于算出来怎么求解了,JJery学长已经知道怎么求解了,聪明的ACMer,你们在知道? Input输入包含多组测试样例,输入的第一行将包含一个正整数T,表示测试样例的数量。每组样例由两行组成,第一行是一个正整数n,第二行...原创 2019-01-24 14:49:56 · 3151 阅读 · 0 评论 -
HDU 2029 回文串 水题
http://acm.hdu.edu.cn/showproblem.php?pid=2029“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。请写一个程序判断读入的字符串是否是“回文”。Input输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。Output如果一个字符串是回文串,则输出"...原创 2019-01-26 22:46:38 · 178 阅读 · 0 评论 -
Codeforces 1132 B 贪心 水题
http://codeforces.com/problemset/problem/1132/Bou came to a local shop and want to buy some chocolate bars. There are nn bars in the shop, ii -th of them costs aiai coins (and you want to buy all of...原创 2019-03-08 11:38:44 · 1004 阅读 · 0 评论 -
Codeforces 1138 A 思维水题
http://codeforces.com/problemset/problem/1138/AArkady invited Anna for a dinner to a sushi restaurant. The restaurant is a bit unusual: it offersnnpieces of sushi aligned in a row, and a customer ...原创 2019-03-13 15:07:19 · 608 阅读 · 0 评论 -
CodeForces 1144A 模拟水题
http://codeforces.com/problemset/problem/1144/AA string is called diverse if it contains consecutive (adjacent) letters of the Latin alphabet and each letter occurs exactly once. For example, the fo...原创 2019-04-03 21:05:04 · 583 阅读 · 0 评论 -
codeforces 1197B Pillars
http://codeforces.com/problemset/problem/1197/BThere are n pillars aligned in a row and numbered from 1 to n.Initially each pillar contains exactly one disk. The i-th pillar contains a disk ha...原创 2019-07-24 17:07:23 · 394 阅读 · 0 评论 -
codeforces 1197 A 水题
http://codeforces.com/problemset/problem/1197/ALet's denote a k-step ladder as the following structure: exactly k+2wooden planks, of whichtwo planks of length at least k+1— the base of the ladd...原创 2019-07-24 16:56:27 · 201 阅读 · 0 评论 -
Codeforces 1153 A Serval and Bus
http://codeforces.com/problemset/problem/1153/AIt is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from k...原创 2019-04-17 14:25:24 · 332 阅读 · 0 评论 -
ccpc 2050 D PASS
Problem Description有 n 个选手参加了 2050 编程竞赛,他们属于 m 个学校,学校的编号为 1 到 m,2050 编程竞赛的 PASS 奖励资格如下:对于一个学校,如果它有 x 个学生参赛,它的参赛学生里成绩最好的 ⌊xk⌋ 人里,每有一个人总排名在前 50% 内(包括50%),就奖励一个 PASS。现在给出每个选手所属的学校和它的排名(假设没有平手),请你帮主办方算...原创 2019-04-14 11:31:49 · 252 阅读 · 0 评论