A.b序列从大到小填a序列中的0,在判断。

#include<bits/stdc++.h>
using namespace std; int n,m,a[],b[]; int main()
{
ios::sync_with_stdio();
cin >> n >> m;
for(int i = ;i <= n;i++) cin >> a[i];
for(int i = ;i <= m;i++) cin >> b[i];
sort(b+,b++m);
reverse(b+,b++m);
int now = ;
for(int i = ;i <= n;i++)
{
if(a[i] == ) a[i] = b[++now];
}
for(int i = ;i <= n;i++)
{
if(a[i-] > a[i])
{
cout << "Yes" << endl;
return ;
}
}
cout << "No" << endl;
return ;
}

B.分一个位置不同和两个位置不同两种情况。一个位置不同的直接改成没出现的数字。两个位置不同的把两种情况都试一下。

#include<bits/stdc++.h>
using namespace std; int n,a[],b[],c[],ok[] = {},x[]; int main()
{
ios::sync_with_stdio();
cin >> n;
for(int i = ;i <= n;i++) cin >> a[i];
for(int i = ;i <= n;i++) cin >> b[i];
int cnt = ;
for(int i = ;i <= n;i++)
{
if(a[i] == b[i]) ok[a[i]] = ;
else x[++cnt] = i;
}
if(cnt == )
{
for(int i = ;i <= n;i++)
{
if(!ok[i]) a[x[]] = i;
}
}
else
{
for(int i = ;i <= n;i++) c[i] = a[i];
for(int i = ;i <= n;i++)
{
if(!ok[i])
{
a[x[]] = i;
ok[i] = ;
break;
}
}
for(int i = ;i <= n;i++)
{
if(!ok[i]) a[x[]] = i;
}
int cnt1 = ,cnt2 = ;
for(int i = ;i <= n;i++)
{
if(a[i] != b[i]) cnt1++;
if(a[i] != c[i]) cnt2++;
}
if(cnt1 != || cnt2 != ) swap(a[x[]],a[x[]]);
}
for(int i = ;i <= n;i++) cout << a[i] << " ";
return ;
}

C.打表每个字母增加每个数值的ans。

#include<bits/stdc++.h>
using namespace std; int n,q,ans[][] = {},cnt[];
string s; int main()
{
ios::sync_with_stdio();
cin >> n >> s >> q;
s = ' '+s;
for(char c = 'a';c <= 'z';c++)
{
memset(cnt,,sizeof(cnt));
for(int i = ;i <= n;i++)
{
cnt[i] = cnt[i-];
if(s[i] != c) cnt[i]++;
}
for(int i = ;i <= n;i++)
{
for(int j = i+;j <= n;j++)
{
ans[c][cnt[j]-cnt[i]] = max(ans[c][cnt[j]-cnt[i]],j-i);
}
}
for(int i = ;i <= n;i++) ans[c][i] = max(ans[c][i-],ans[c][i]);
}
while(q--)
{
int x;
cin >> x >> s;
cout << ans[s[]][x] << endl;
}
return ;
}

D.判断每个环在第几层,0层和偶数层的加,奇数层的减。

#include<bits/stdc++.h>
#define PI acos(-1)
using namespace std; int n,x[],y[],r[],cnt[] = {}; int main()
{
ios::sync_with_stdio();
cin >> n;
for(int i = ;i <= n;i++) cin >> x[i] >> y[i] >> r[i];
for(int i = ;i <= n;i++)
{
for(int j = ;j <= n;j++)
{
if(i == j) continue;
if(sqrt(1.0*(x[i]-x[j])*(x[i]-x[j])+1.0*(y[i]-y[j])*(y[i]-y[j])) <= r[j]-r[i]) cnt[i]++;
}
}
double ans = ;
for(int i = ;i <= n;i++)
{
if(cnt[i] == || cnt[i]%) ans += PI*r[i]*r[i];
else ans -= PI*r[i]*r[i];
}
cout << fixed << setprecision() << ans << endl;
return ;
}

Codeforces_814的更多相关文章

随机推荐

  1. HR系列GPS北斗时间同步服务器在电力系统典型应用

    HR系列GPS北斗时间同步服务器在电力系统典型应用 时间同步系统主要由主时钟.若干从时钟.时间信号传输介质组成.根据时间同步现场的不同要求,时间同步系统的结构配置有多种形式,主要分为三种:基本式.主从 ...

  2. ASP.Net Core 3.0 中使用JWT认证

    JWT认证简单介绍     关于Jwt的介绍网上很多,此处不在赘述,我们主要看看jwt的结构.     JWT主要由三部分组成,如下: HEADER.PAYLOAD.SIGNATURE HEADER包 ...

  3. 低副瓣阵列天线综合2 matlab HFSS

    接着继续研究阵列天线设计,得到了电流幅度分布或功率分布之后,就可以进行阵列设计或馈电网络设计了,之前利用HFSS仿真过单列的串馈天线,后面会继续复习熟悉一下,本次我找了一篇硕士论文利用威尔金森功分器来 ...

  4. Http GetPost网络请求

    using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System ...

  5. vnpy源码阅读学习(1):准备工作

    vnpy源码阅读学习 目标 通过阅读vnpy,学习量化交易系统的一些设计思路和理念. 通过阅读vnpy学习python项目开发的一些技巧和范式 通过vnpy的设计,可以用python复现一个小型简单的 ...

  6. echarts设置网格线颜色

    xAxis: { type: 'value', //设置网格线颜色 splitLine: { show: true, lineStyle:{ color: ['#315070'], width: 1, ...

  7. vue+bootstrap4+mybatis分页

    先看效果 Springboot+Mybatis+Pagehelper分页具体实现略. Controller返回数据 @GetMapping("/findByPage") publi ...

  8. 玩转Django2.0---Django笔记建站基础四(视图)

    第四章 视图 4.1 探究视图 一.视图说明 视图(View)是Django的MTV架构模式的V部分,主要负责处理用户请求和生成相应的相应部分,然后在页面或其它类型文档中显示.也可以理解为视图是MVC ...

  9. Nito.AsyncEx 这个库

    有一个非常聪明的小伙子 (我高度赞扬) 叫 Stephen Cleary ,他写了一个很棒的 Extension 集,共同参与开发的还有 Stephen Toub (他显然是经验丰富的),所以我充分信 ...

  10. python读取json文件

    比如下图json数据,场景需要读取出wxid这项数据,然后传给后面的函数去使用 具体的脚本为 import json f =open('d:\\1024.json',encoding='utf-8') ...