比赛链接
A题:
思路:签到题。
代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
int t,n,m;
int arr[maxn];
int main()
{ios::sync_with_stdio(false);cin>>t;while(t--){cin>>n>>m;if(n<=4){cout<<"NO"<<endl;}else{if(n%m) cout<<"NO"<<endl;else cout<<"YES"<<endl;}}return 0;
}

B题:
思路:签到题,把题目给的要求的不等式移项,然后发现直接将数组从大到小排序就一定符合条件。
代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
int t,n,m;
int arr[maxn];
bool comp(int a,int b)
{return a>b;
}
int main()
{ios::sync_with_stdio(false);cin>>t;while(t--){cin>>n;for(int i=1;i<=n;i++){cin>>arr[i];}sort(arr+1,arr+1+n,comp);for(int i=1;i<=n;i++){if(i==1) cout<<arr[i];else cout<<" "<<arr[i];}cout<<endl;}return 0;
}

C题:
思路:类似于二进制1100110这样,看每一位上需不需要拿上一个,模拟即可,最终k的 i 次方被用过一次以上的就不合法。
代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
ll t,n,m;
ll arr[maxn];
int rec[105];
int main()
{ios::sync_with_stdio(false);cin>>t;while(t--){memset(rec,0,sizeof(rec));cin>>n>>m;for(int i=1;i<=n;i++){cin>>arr[i];}int flag=1;for(int i=1;i<=n;i++){if(arr[i]==0) continue;if(arr[i]==1){rec[0]++;continue;}ll z=arr[i];ll tmp=1;int num=0;while(tmp<=z){tmp=tmp*m;num++;}tmp=tmp/m;num--;while(z){while(z>=tmp){z=z-tmp;rec[num]++;}tmp=tmp/m;num--;}}for(int i=0;i<=103;i++){if(rec[i]>1){flag=0;break;}}if(flag) cout<<"YES"<<endl;else cout<<"NO"<<endl;}return 0;
}

D题:
思路:显然需要推式子,一共m个人,数列一共n个数,不同的数字n-1个,因此需要从m里面先选出n-1个不同的数字,C(m,n-1),然后n-1个数中最大的数字一定是中转点,中转点不可以成为出现两次的那个数字,所以要从剩下的 n-2 个数字中找出一个出现两次的数字,因此需要乘上一个(n-2),剩下的n-3个数字要么在中转点左边要么就是右边,而出现两次的数字是不需要考虑的,由于剩下n-3个数字可以左可以右,所以还需要乘以一个2的(n-3)次方。套个lucas和快速幂可以算出来答案。
需要注意的是,n为2的时候,快速幂中的次数会是-1,会卡死。因此2的话特判,n是2的时候直接输出0.
板子是网上找的套的。

代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;typedef long long LL;LL fast_power(LL a,LL b,LL p){LL ans=1;a%=p;while(b){if(b&1) ans=(ans*a)%p;a=(a*a)%p;b>>=1;}return ans;
}LL C(LL a,LL b,LL p){if(b>a) return 0;if(a==b) return 1;LL ans1=1,ans2=1;for(LL i=1;i<=b;i++){ans1=ans1*(a-i+1)%p;ans2=ans2*i%p;}return ans1*fast_power(ans2,p-2,p)%p;
}LL Lucas(LL a,LL b,LL p){if(b==0) return 1;return C(a%p,b%p,p)*Lucas(a/p,b/p,p)%p;
}int main(){int t;LL n,m,p;cin>>n>>m;p=998244353;LL fin=0;if(n==2){cout<<"0"<<endl;return 0;}LL zz=(Lucas(m,n-1,p)*fast_power(2,n-3,p))%p;fin=zz;cout<<(fin*(n-2))%p<<endl;return 0;
}

E题:

思路:n的大小是500,观察到转移是一个一个区间的转移,因此基本上确定区间dp。需要注意的是转移过程中需要记录每一个区间左边右边的值来辅助转移。
代码写的是记忆化搜索型的区间DP。

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn=550;
int dp[maxn][maxn];
int t,n,m;
int arr[maxn];
int ll[maxn][maxn],rr[maxn][maxn];
int solve(int l,int r)
{if(l==r){dp[l][r]=1;ll[l][r]=rr[l][r]=arr[l];return 1;}if(dp[l][r]<=n) return dp[l][r];for(int i=l;i<r;i++){if(dp[l][r]>(solve(l,i)+solve(i+1,r)-(rr[l][i]==ll[i+1][r]))){dp[l][r]=dp[l][i]+dp[i+1][r]-(rr[l][i]==ll[i+1][r]);ll[l][r]=ll[l][i];rr[l][r]=rr[i+1][r];if(rr[l][i]==ll[i+1][r]){if(dp[l][i]==1) ll[l][r]++;if(dp[i+1][r]==1) rr[l][r]++;}}}return dp[l][r];
}
int main()
{ios::sync_with_stdio(false);cin>>n;for(int i=1;i<=n;i++){cin>>arr[i];}int fin=n;memset(dp,0x3f,sizeof(dp));fin=min(fin,solve(1,n));cout<<fin<<endl;return 0;
}

呼,下班了。

Codefoece Educational Codeforces Round 83 (Rated for Div. 2)题解,(ABCDE)相关推荐

  1. Educational Codeforces Round 123 (Rated for Div. 2)(ABCDE)

    Educational Codeforces Round 123 (Rated for Div. 2)(ABCDE) A. Doors and Keys 题意:给定长度为6的字符串,问是否可以通关,其 ...

  2. Educational Codeforces Round 117 (Rated for Div. 2)题解(A~D)

    Educational Codeforces Round 117 (Rated for Div. 2) 今天这场没打,赛后从九点半到十一点把前面四个题目给补了一下,E题明天有时间看看能不能弄出来. A ...

  3. Educational Codeforces Round 140 (Rated for Div. 2)题解

    看看时间还有十几分钟,开不出来题了,写个题解 A. Cut the Triangle 检查是不是直角边平行于坐标轴的直角三角形即可 这里可以用异或来写,代码较为简洁,我就不改了,直接贴上我的丑代码 c ...

  4. Educational Codeforces Round 133 (Rated for Div. 2) 题解 CD

    D: 这是一道好dp(对我来说) 我做的时候有想过正解那个方式当考虑到可能有重复就没有深入思考了 假设dp[i][j]代表第i次j的方案数 此时我们可以发现dp[i][j]=sum(dp[i-1][j ...

  5. Educational Codeforces Round 105 (Rated for Div. 2) 题解

    Educational Codeforces Round 105 (Rated for Div. 2) A. ABC String 枚举ABC分别为"( "和 " )&q ...

  6. Educational Codeforces Round 36 (Rated for Div. 2) 题解

    Educational Codeforces Round 36 (Rated for Div. 2) 题目的质量很不错(不看题解做不出来,笑 Codeforces 920C 题意 给定一个\(1\)到 ...

  7. Educational Codeforces Round 76 (Rated for Div. 2) 题解

    Educational Codeforces Round 76 题解 比赛链接 A. Two Rival Students #include<bits/stdc++.h> using na ...

  8. Educational Codeforces Round 93 (Rated for Div. 2) 题解

    目录 A.CF1398A Bad Triangle(模拟) B.CF1398B Substring Removal Game(贪心) C.CF1398C Good Subarrays(映射) D.CF ...

  9. Educational Codeforces Round 107 (Rated for Div. 2) 题解

    文章目录 A. Review Site B. GCD Length C. Yet Another Card Deck D. Min Cost String E. Colorings and Domin ...

最新文章

  1. Linux的归档及压缩,Linux的cron时间计划任务, NTP网络时间协议 , 查看网络连接...
  2. 人工智能(5)---一文解读人工智能创业的5大坑
  3. 盘点2020中国IT上市企业100强,贵司上榜了吗?
  4. 自定义博客园地址栏ico图标 标签logo
  5. 数据库设置_CentOS7 - 设置MySQL数据库
  6. c语言 函数的参数传递示例_isgreaterequal()函数以及C ++中的示例
  7. Scala的函数式编程
  8. 编程小白模拟简易比特币系统,手把手带你写一波!(附代码)
  9. [转帖] BMC安全隐患
  10. Bfs 逃脱(牛客网)
  11. 精密电阻阻值表丝印大全
  12. 基于多源传感器融合的导航定位综述方法分析
  13. 银河麒麟鸿蒙计划,银河麒麟Kydroid2.0发布,支持海量安卓APP,要抢鸿蒙的风头吗?...
  14. 金融、股票、投行的常见术语及一些简单区分
  15. uva-1645-递推
  16. 用计算机画函数图象,信息技术应用 用计算机画函数图象 .doc
  17. 彻底解决Qt中文乱码以及汉字编码的问题(UTF-8/GBK)
  18. java开发工具还有那些?
  19. “希希敬敬对”团队作业——敏捷冲刺7
  20. Flex Builder 3.0 开发环境

热门文章

  1. Revit翻模技巧丨怎么一次性翻转所有墙体?
  2. undefined reference to 解决
  3. sicily1198
  4. 使用PTGui用360度全景图制作Unity3D天空盒
  5. 计算机系统重置运行程序数据,Win10电脑重做系统后数据恢复,深度重置也不用担心...
  6. 上海交通大学方浩树:人类行为理解与机器人物体操作
  7. 知乎问答丨对于大一即将进入大二的学生有什么建议?
  8. 使用timeit测试python语句执行的时间
  9. 佳能 digital photo professional直接安装方法
  10. 旋转LED:光の翼电子钟