随笔分类 -  构造

摘要:A:http://codeforces.com/contest/1447/problem/A 解析: 直接输出n个数,1~n即可。 #include<iostream> #include<cstdio> #include<cstdio> #include<cstring> #include<algo 阅读全文
posted @ 2020-11-16 20:52 liyexin 阅读(105) 评论(0) 推荐(0)
摘要:A:http://codeforces.com/contest/1443/problem/A 解析: 考虑从2*n开始,每次+2构造 #include<cstdio> #include<cstring> #include<vector> #include<set> #include<algorith 阅读全文
posted @ 2020-11-03 21:39 liyexin 阅读(109) 评论(0) 推荐(0)
摘要:地址:http://codeforces.com/contest/1436/problem/B 题意: 输出一个n*n的矩阵,只包含非素数,而且每行,每列的和为素数 解析: 先让矩阵所有元素为1 n是素数的话,直接输出即可。 否则,找出n之前的第一个合数,求出差cha 这个cha,就是每行需要几个1 阅读全文
posted @ 2020-10-26 19:18 liyexin 阅读(213) 评论(0) 推荐(0)
摘要:地址:http://codeforces.com/contest/1427/problem/A 题意: 给出a[],对其进行重排列,保证不存在 b1+b2+...+bk!=0,k=1,2,3....n 解析: 脑子秀逗了,这题差点没搞出来。 首先求一下数组和sum 1:sum==0 很明显,一定不行 阅读全文
posted @ 2020-10-11 20:43 liyexin 阅读(199) 评论(0) 推荐(0)
摘要:A:http://codeforces.com/contest/1419/problem/A 解析: 稀里糊涂过得,不想说了。。。 #include <bits/stdc++.h> #include<vector> using namespace std; typedef long long ll; 阅读全文
posted @ 2020-09-21 21:11 liyexin 阅读(224) 评论(0) 推荐(0)
摘要:A:http://codeforces.com/contest/1409/problem/A 题意: a,b, 每一步可a+k或a-k,1<=k<=10,a=b最少需要几步 解析: 优先+-10,不足的一定<10,一步即可 #include<bits/stdc++.h> #include<map> 阅读全文
posted @ 2020-09-05 23:34 liyexin 阅读(254) 评论(0) 推荐(0)
摘要:A:http://codeforces.com/contest/1391/problem/A 题意: 输出一个排列,满足: 对于其任意的连续子序列pi...pj都满足:pi OR pi+1 OR pi+2....OR pj>=j-i+1 解析: 顺手打了个表,发现x | y >= max(x,y), 阅读全文
posted @ 2020-08-10 17:24 liyexin 阅读(179) 评论(0) 推荐(0)
摘要:地址:https://ac.nowcoder.com/acm/contest/5672/B 题意: 给出n*m个口罩,把它们分成k组,可以取:n组,每组m个口罩,m组,每组n个口罩 求最小k,并按字典序从大到小输出 解析: 来自:https://www.cnblogs.com/xyq0220/p/1 阅读全文
posted @ 2020-08-03 12:04 liyexin 阅读(136) 评论(0) 推荐(0)
摘要:地址:http://codeforces.com/contest/1389/problem/C 题意: 含0~9的字符串,删除最少的字符,实现: t2t3....tnt1==tnt1t2......tn-1 解析: 可以发现,当长度为奇数的时候,t1=t2=t3...tn,这个时候,整个字符串必须全 阅读全文
posted @ 2020-07-31 23:38 liyexin 阅读(175) 评论(0) 推荐(0)
摘要:地址:https://ac.nowcoder.com/acm/contest/5671/E 题意: 构造一个只含1~n的序列,使得对于每一个长度在[1,n]的i,序列都存在一段长度为i的连续子序列,它的和%n==k 解析: 正着看不好看,来倒着分析 首先是i==n的情况,也就是序列总和,如果它%n! 阅读全文
posted @ 2020-07-29 10:23 liyexin 阅读(275) 评论(0) 推荐(0)