构造
幽殇默
他时若遂凌云志,敢笑黄巢不丈夫。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
B. Sorted Adjacent Differences【1200 / 思维 构造】
https://codeforces.com/problemset/problem/1339/B 排序后从中间,螺旋式走即可,注意区分数组个数的奇偶。 证明: abs(a[i]-a[i+1]) < abs(a[i-1]+a[i+1]) #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int a[N],ans[N],n,t; int main(void) { cin>>t; while(t-.原创 2021-11-21 22:44:48 · 684 阅读 · 0 评论 -
D. Game With Array【1400 / 思维 构造】
https://codeforces.com/problemset/problem/1355/D 考虑一种构造方法,我们让前面的(n-1)个数都为1 并让k为n 这样前(n-1)项的任意前缀必小于k。 那么最后一项是s-(n-1) 如果最后一项小于等于k则无解了,因为这样就可以拼凑出来k了。 证明: 设最后一项为w=s-(n-1)>k 故任何有w的子序列的值都是大于k的。没有的话我们上面已经证明了都是小于k的。 那么s-k==s-n w=s-(n-1)>s-n 这是显然的,故也都大于s-k .原创 2021-11-12 17:18:35 · 495 阅读 · 0 评论 -
D. Anti-Sudoku【1300 / 思维 构造】
https://codeforces.com/problemset/problem/1335/D 选定一个字母a再选定一个字母b将所有的字母b变成字母a即可。 #include<bits/stdc++.h> using namespace std; string s[10]; int main(void) { int t; cin>>t; while(t--) { for(int i=0;i<9;i++) cin>>s[i]; for(int i=0.原创 2021-11-02 20:45:30 · 152 阅读 · 0 评论 -
B. Same Parity Summands【1200 / 构造】
https://codeforces.com/problemset/problem/1352/B 就是构造分为以下几种情况: 要分为m个数,分m-1个1 剩下的数如果还是奇数说明可以,那么就输出 要分为m个数,分m-1个2 剩下的数如果还是偶数说明可以,那么就输出 其它的就是不可行的。 #include<bits/stdc++.h> using namespace std; int main(void) { int t; cin>>t; while(t--) { in.原创 2021-10-28 12:24:18 · 221 阅读 · 0 评论 -
C. Drazil and Factorial【1400 / 构造】
https://codeforces.com/problemset/problem/515/C 题目给的意思就是不包含0,1 且 f(x)==f(a) 且x要尽量的大。 自己的垃圾模拟做法: #include<bits/stdc++.h> using namespace std; typedef long long int LL; bool check(int x) { for(int i=2;i<=x/i;i++) if(x%i==0) return true; ret.原创 2021-10-27 10:34:55 · 221 阅读 · 0 评论 -
B. Phoenix and Beauty【1400 / 构造 构造循环结】
https://codeforces.com/problemset/problem/1348/B 如果给定的数组的元素种类大于我们的m,则一定构造不出来。 否则的话,我们就构造一个不重复的m的序列,输出n次即可。 相关题解 相关题解 相关题解 #include<bits/stdc++.h> using namespace std; int a[10004]; int main(void) { int t; cin>>t; while(t--) { int n,m; ci.原创 2021-10-27 09:18:54 · 135 阅读 · 0 评论 -
A. Jeff and Digits【1000 / 构造】
https://codeforces.com/problemset/problem/352/A 构造前面必须是9的倍数个五,后面有多少个0输出多少个,至少一个。 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int a[N],n; map<int,int>mp; int main(void) { cin>>n; for(int i=1;i<=n;i++) cin>>.原创 2021-10-13 09:18:38 · 112 阅读 · 0 评论 -
D1. Sage‘s Birthday (easy version)【1000 / 思维 构造】
https://codeforces.com/problemset/problem/1419/D1 构造,后面一半的数依次放在偶数位,前面的依次放在奇数位。 #include<bits/stdc++.h> using namespace std; const int N=1e5*2+10; int a[N],b[N],n; int main(void) { cin>>n; for(int i=0;i<n;i++) cin>>a[i]; sort(a,a+n).原创 2021-10-08 10:24:34 · 126 阅读 · 0 评论 -
157. Two Sets【数学 构造】
https://www.papamelon.com/problem/157 通过观察你会发现和为奇数一定无解,和为偶数一定有解。 我们先从大到小的取一个集合,剩下的为一个集合。 #include<bits/stdc++.h> using namespace std; int main(void) { int n; cin>>n; long long int sum=0; for(int i=1;i<=n;i++) sum+=i; vector<int>st.原创 2021-09-27 17:19:49 · 446 阅读 · 0 评论 -
B. Captain Flint and a Long Voyage【1000 / 构造】
https://codeforces.com/problemset/problem/1388/B 首先你会发现我们只能选9或者8 因为9或8二进制都是4位。其他的都小于4位, 故就看后面有多少个8了,前面的必须都是9. #include<bits/stdc++.h> using namespace std; int main(void) { int t; cin>>t; while(t--) { int n; cin>>n; int cnt1,cnt2; .原创 2021-09-23 17:56:02 · 123 阅读 · 0 评论 -
A. Regular Bracket Sequences【1000 / 构造】
先()剩下的不足直接补() 然后再(()) 剩下的不足直接补() 接着((()))剩下的不足直接补() 以此类推 #include<bitsdc++.h> using namespace std; int main(void) { int t; cin>>t; while(t--) { int n; cin>>n; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) cout<<"(.原创 2021-09-21 23:07:26 · 297 阅读 · 0 评论 -
B. Lovely Palindromes【1000 / 构造 找规律】
https://codeforces.com/problemset/problem/688/B 打表,你会发现,输入的东西翻转后拼接起来就是第n个 #include<bits/stdc++.h> using namespace std; int main(void) { string s; cin>>s; string ans=s; reverse(s.begin(),s.end()); ans+=s; cout<<ans; return 0; } ...原创 2021-09-21 10:21:36 · 123 阅读 · 0 评论 -
A. Little Artem【1000 / 构造】
https://codeforces.com/problemset/problem/1333/A WBB… BB… … 只要第一个是W其它都是B即可 B的好的有2个 W的好的有1个 #include<bits/stdc++.h> using namespace std; int main(void) { int t; cin>>t; while(t--) { int n,m; cin>>n>>m; for(int i=1;i<=n;i++.原创 2021-09-20 16:19:41 · 108 阅读 · 0 评论 -
C. Not Adjacent Matrix【1000 / 构造】
https://codeforces.com/problemset/problem/1520/C 不让相邻的数挨着。 这样构造即可。 #include<bits/stdc++.h> using namespace std; int a[105][105]; int main(void) { int t; cin>>t; while(t--) { int n; cin>>n; if(n!=2) { int k=1; for(int i=0.原创 2021-09-19 21:58:38 · 263 阅读 · 0 评论 -
A. Bad Ugly Numbers 【1000 / 构造题】
https://codeforces.com/problemset/problem/1326/A 构造一个n位的数,不能被其单位上的每一个数整除。 如果n==1一定无解。 构造方法: 233… 499… 677… 等…任选一种即可 #include<bits/stdc++.h> using namespace std; int main(void) { int t; cin>>t; while(t--) { int n; cin>>n; if(n==1.原创 2021-09-19 17:31:38 · 170 阅读 · 0 评论 -
A. Nastia and Nearly Good Numbers【1000 / 思维 构造】
https://codeforces.com/problemset/problem/1521/A 几乎好的数是x%a==0 && x%(a*b)!=0 好的数是x%(a*b)==0 所以如果b==1 那么结果一定不存在 A(a+b)=ABc a+b=B*c 让c等于1,剩下的数随便分B 当B=2时乘以2 一个分1 一个分3即可。 #include<bits/stdc++.h> using namespace std; typedef long long int LL; int .原创 2021-09-19 10:27:45 · 140 阅读 · 0 评论
分享