A. Best Subsegment

题意 找 连续区间的平均值  满足最大情况下的最长长度

思路:就是看有几个连续的最大值

 #include<bits/stdc++.h>
using namespace std;
const int maxn= 1e5+;
int a[maxn];
int main(){
int n;
scanf("%d",&n);
int maxnum=;
for(int i=;i<n;i++)scanf("%d",&a[i]),maxnum=max(maxnum,a[i]);
int ans=;
int temp=;
for(int i=;i<n;i++){
if(maxnum==a[i]&&i+<n&&a[i]==a[i+])temp++;
else ans=max(temp,ans),temp=;
}
printf("%d",ans);
return ;
}

B. Emotes

题意: n个数字 (正)  每个可以用任意次   一共m次   一个数字不能用超过连续k次  问m次 用的数字的和的最大值是多少

思路:直接找最大和次大  最大k次+次大1次 循环 最后处理一下余数即可

 #include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+;
int a[maxn];
int main(){
int n,m,k;
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<n;i++){
scanf("%d",&a[i]);
}
sort(a,a+n);
long long ans=;
int first=a[n-],second=a[n-];
ans=1ll*m/(k+)*(1ll*first*k+second);
m%=(k+);
ans+=1ll*m*first;
printf("%I64d\n",ans); return ;
}

C. Magic Ship

题意:给出n个风向  风是循环运作的 并且给出起点和终点(二维)问可否到达终点

思路:将x y分解  对风求前缀和 二分找步数  看是否满足题意  这里记得二分范围要大 1e18 不然就会gg(虽然过了 但是我总感觉有点怪怪的好像能出数据hack 可能是有完备性证明的,只是我太菜不会证吧。。)

 #include<bits/stdc++.h>
#define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;i++)
#define MS(arr,arr_value) memset(arr,arr_value,sizeof(arr))
#define F first
#define S second
#define pii pair<int ,int >
#define mkp make_pair
#define pb push_back
using namespace std;
const long long inf=1e18;
typedef long long ll;
const int maxn=1e5+;
map<char,pii>mp;
ll sumx[maxn],sumy[maxn];
char s[maxn];
void init(){
mp['U']={,};mp['D']={,-};mp['L']={-,};mp['R']={,};
}
int n;
ll X1,Y1,X2,Y2;
bool check(ll mid){
ll q=mid/n,r=mid%n;
ll nx=X1+sumx[n]*q+sumx[r];
ll ny=Y1+sumy[n]*q+sumy[r];
return (abs(nx-X2)+abs(ny-Y2))<=mid;
}
int main(){
init();
scanf("%lld%lld%lld%lld",&X1,&Y1,&X2,&Y2);
scanf("%d",&n);
scanf("%s",s+);
FOR(i,,n){
sumy[i]=sumy[i-]+mp[s[i]].S;
sumx[i]=sumx[i-]+mp[s[i]].F;
}
ll l=,r=inf;
ll ans=inf;
while(l<=r){
ll mid=l+r>>;
if(check(mid))ans=mid,r=mid-;
else l=mid+;
}
if(ans!=inf)cout<<ans<<endl;
else cout<<-<<endl; return ;
}

D. Magic Gems

题意  一个特殊基因可以分成m个普通基因  问刚好n个基因有多少种组成方式   1<=n<=1e18  2<=m<=100

思路:看这数据范围 这题目就一股浓浓的矩阵快速幂的味道  直接列出转移式 构造矩阵  dp[n]=dp[n-1]+dp[n-m];

(1....10) 大概就这意思吧 然后直接套矩阵就行了   (写的时候傻逼用int读long long) m*m的矩阵

(1.......0)
(01......0)

(001......0)

.....

 #include<bits/stdc++.h>
#define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;i++)
#define MS(arr,arr_value) memset(arr,arr_value,sizeof(arr))
#define F first
#define S second
#define pii pair<int ,int >
#define mkp make_pair
#define pb push_back
using namespace std;
const long long inf=1e18;
typedef long long ll;
const int mod=1e9+;
long long n,m;
struct mat{
ll m[][];
mat(){
MS(m,);
}
};
mat Mul(mat a,mat b,int n){
mat res;
int i,j,k;
for( i=;i<=n;i++){
for( j=;j<=n;j++){
res.m[i][j]=;
for(k=;k<=n;k++){
res.m[i][j]=(res.m[i][j]+(a.m[i][k]*b.m[k][j])%mod+mod)%mod;
}
}
}
return res;
}
mat fpow(mat a,ll b,int n){
mat ans;
for(int i=;i<=n;i++)ans.m[i][i]=;
while(b){
if(b&)ans=Mul(ans,a,n);
a=Mul(a,a,n);
b>>=;
}
return ans;
}
const int maxn=1e5+;
int dp[];
int main(){
scanf("%lld%lld",&n,&m);
if(n<=m){
if(n==m)cout<<<<endl;
else
cout<<<<endl;
return ;
}
dp[]=;
for(int i=;i<m;i++)dp[i]=;
dp[m]=dp[]+dp[m-];
mat d;
d.m[][]=;d.m[][m]=;
for(int i=;i<=m+;i++)d.m[i][i-]=;
mat e;
for(int i=;i<=m+;i++){
e.m[m+-i][]=dp[i-];
}
/* for(int i=1;i<=m+1;i++){
cout<<e.m[i][1]<<endl;
}
for(int i=1;i<=m+1;i++){
for(int j=1;j<=m+1;j++){
cout<<d.m[i][j]<<" ";
}
cout<<endl;
}
*/ d=fpow(d,n-m,m+);
d=Mul(d,e,m+);
cout<<(d.m[][])%mod<<endl; return ;
}

Educational Codeforces Round 60 (Rated for Div. 2)的更多相关文章

  1. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  2. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

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

    Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best ...

  4. Educational Codeforces Round 60 (Rated for Div. 2)D(思维,DP,快速幂)

    #include <bits/stdc++.h>using namespace std;const long long mod = 1e9+7;unordered_map<long ...

  5. Educational Codeforces Round 60 (Rated for Div. 2)E(思维,哈希,字符串,交互)

    #include <bits/stdc++.h>using namespace std;int main(){ string t; cin>>t; int n=t.size() ...

  6. Educational Codeforces Round 60 (Rated for Div. 2) 即Codeforces Round 1117 C题 Magic Ship

    time limit per test 2 second memory limit per test 256 megabytes input standard inputoutput standard ...

  7. Educational Codeforces Round 60 (Rated for Div. 2) D. Magic Gems(矩阵快速幂)

    题目传送门 题意: 一个魔法水晶可以分裂成m个水晶,求放满n个水晶的方案数(mol1e9+7) 思路: 线性dp,dp[i]=dp[i]+dp[i-m]; 由于n到1e18,所以要用到矩阵快速幂优化 ...

  8. Educational Codeforces Round 60 (Rated for Div. 2) E. Decypher the String

    题目大意:这是一道交互题.给你一个长度为n的字符串,这个字符串是经过规则变换的,题目不告诉你变换规则,但是允许你提问3次:每次提问你给出一个长度为n的字符串,程序会返回按变换规则变换后的字符串,提问3 ...

  9. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

随机推荐

  1. 控制台程序读取Excel设置角色权限

    摘要: 本人微信公众号:微软动态CRM专家罗勇 ,回复283或者20181118可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me ...

  2. jquery获取内容和属性的方法

    通过jquery如何捕获文本内容和属性? text(),html(),val()及attr(). attr()更具有普遍性,元素text属性和表单value属性,可以通过attr()操作. <! ...

  3. kafka环境搭建

    kafka环境搭建 for mac 对应qq群号:616961231 在之前的文章中, 有学习能力和兴趣爱好的同学,自己动手维护测试环境,丰衣足食是最好的办法,今天我们来讲讲kafka在mac上的安装 ...

  4. Vue双向绑定原理,教你一步一步实现双向绑定

    当今前端天下以 Angular.React.vue 三足鼎立的局面,你不选择一个阵营基本上无法立足于前端,甚至是两个或者三个阵营都要选择,大势所趋. 所以我们要时刻保持好奇心,拥抱变化,只有在不断的变 ...

  5. Docker Data Center系列(一)- 快速搭建云原生架构的实践环境

    本系列文章演示如何快速搭建一个简单的云原生架构的实践环境. 基于这个基础架构,可以持续部署微服务架构的应用栈,演练敏捷开发过程,提升DevOps实践能力. 1 整体规划 1.1 拓扑架构 1.2 基础 ...

  6. Proxmox VE中出现TASK ERROR: command 'apt-get update' failed: exit code 100的解决方法

    问题描述: 出现这个错误一般在WEB或者在Proxmox VE的服务器上面能看到日志: PVE中出现TASK ERROR: command 'apt-get update' failed: exit ...

  7. window批处理修改计算机名

    一.需要重启 @echo offset /p pcnanme=请输入计算机的名字:reg add HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Com ...

  8. 如何制作中文Javadoc包,并导入到Eclipse

    原理:使用chm转换工具将chm文件转换为zip文件,导入eclipse中即可. 准备 JDK1.9 API 中文 谷歌翻译版:http://www.pc6.com/softview/SoftView ...

  9. 转 Angular2优质学习资源收集

    文档博客书籍类 官方网站: https://angular.io 中文站点: https://angular.cn Victor的blog(Victor是Angular路由模块的作者): https: ...

  10. Python开发【内置模块篇】日志模块

    logging配置 import logging logging.basicConfig(level=logging.WARNING, format='%(asctime)s %(filename)s ...