随笔分类 -  Codeforces

摘要:codeforces 1303 题解 A. Erasing Zeroes 想让字符串中的 $1$ 连续,而我们能做的只有删 $0$ ,则需要删去除开头以及结尾外的 所有 $0$ 块。所以从头扫一遍统计开头 $0$ 块,从尾扫一遍统计结尾 $0$ 块,再用 $0$ 的数量减去这两部分即可,可能为负所以 阅读全文
posted @ 2020-02-13 11:42 Asurudo 阅读(447) 评论(0) 推荐(0)
摘要:codeforces 1300 题解 A. Non zero 你可以对数组中任何一个元素进行操作,目的让他们的加和和乘积都不为 $0$ 。想想什么时候加和和乘积为 $0$。 若数组中有至少一个 $0$ ,则数组乘积为 $0$ 若数组中正负加和互为相反数,则数组加和为 $0$ ,否则不为 $0$ 则若 阅读全文
posted @ 2020-02-10 11:24 Asurudo 阅读(429) 评论(0) 推荐(0)
摘要:codeforces 1296 题解 A. Array with Odd Sum 想要数组加和为奇数,可以从数组长度是奇数还是偶数着手 若数组长度为偶数,则数组全奇或全偶必定不能构造满足题目要求的数列 若数组长度为奇数,则数组全偶必定不能构造满足题目要求的数列 B. Food Buying 原谅我不 阅读全文
posted @ 2020-02-06 12:54 Asurudo 阅读(365) 评论(0) 推荐(0)
摘要:codeforces 1291 题解 A. Even But Not Even 要求这个数本身不能被 $2$ 整除,加和可以被 $2$ 整除,那我们分类讨论 若该数本身已经不能被 $2$ 整除,但是加和可以,那我们什么都不用做即可;若加和不可以,我们从后往前删一个奇数即可。 若该数本身就不能被 $2 阅读全文
posted @ 2020-02-04 11:02 Asurudo 阅读(302) 评论(0) 推荐(0)
摘要:codeforces 1295 题解 A. Display The Number 给你可显示的总数,让你凑个最大的数,很明显,抽象的思想就是“好钢要用在刀刃上”,如果可显示的数字越大,所消耗的越小,他自然更好。 我们观察一下各个数字的消耗情况: | 0 | 1 | 2 | 3 | 4 | 5 | 6 阅读全文
posted @ 2020-01-30 10:39 Asurudo 阅读(479) 评论(0) 推荐(1)
摘要:二分查找的典型应用,寻找虚无的值代入测试 阅读全文
posted @ 2019-08-05 10:57 Asurudo 阅读(301) 评论(0) 推荐(0)
摘要:数学题,总和为偶数且最大的数不到总和的一半就输出YES 阅读全文
posted @ 2019-08-05 10:13 Asurudo 阅读(325) 评论(0) 推荐(0)
摘要:1 #include <bits/stdc++.h> 2 #define _for(i,a,b) for(int i = (a);i < b;i ++) 3 typedef long long ll; 4 using namespace std; 5 inline ll read() 6 { 7 ll ans = 0; 8 char ch = getchar(), last = ' '; 9 wh 阅读全文
posted @ 2019-08-05 09:37 Asurudo 阅读(286) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 10 using namespace std; 11 12 #define _for(i,a,b) for(int i = (a);i = b; 21 ... 阅读全文
posted @ 2018-10-27 16:26 Asurudo 阅读(269) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int main() 8 { 9 int n; 10 while(cin >> n) 11 { 12 if(n==1) 13 { 14 cout v(26,0); ... 阅读全文
posted @ 2018-08-22 10:09 Asurudo 阅读(299) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #define DEF 0x3f3f3f3f 7 using namespace std; 8 9 int main() 10 { 11 int T; 12 scanf("%d",&T); 13 while(T --) 14 ... 阅读全文
posted @ 2018-08-21 12:34 Asurudo 阅读(206) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 bool sppalindjudge(string s,int n) 10 { 11 char* pre = &s[0]; 12 char* end = &s[n-1]; 13 ... 阅读全文
posted @ 2018-08-21 08:59 Asurudo 阅读(301) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 int main() 10 { 11 int n,k; 12 while(cin >> n >> k) 13 { 14 string input; 15 ... 阅读全文
posted @ 2018-08-18 10:16 Asurudo 阅读(225) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 int main() 10 { 11 long long int n,k; 12 while(cin >> n >> k) 13 { 14 if(n*2-1<... 阅读全文
posted @ 2018-08-18 09:23 Asurudo 阅读(181) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 int main() 10 { 11 int n,m; 12 while(cin >> n >> m) 13 { 14 string s,t; 15 ... 阅读全文
posted @ 2018-08-18 08:40 Asurudo 阅读(175) 评论(0) 推荐(0)