Codeforces Round 909 (Div3)(本菜鸟只补到了E)
Codeforces Round 909 (Div.3)
A. Game with Integers
水题,就是可以被3整除的输出“Second”,不能被3整除的输出“First”
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
if(n%3) cout<<"First"<<endl;
else cout<<"Second"<<endl;
}
return 0;
}
B.250 Thousand Tons of TNT
k是n的因子就可以用for(int i=1;i<=n/i;i++)来找到因子,从而来分组
注:INF不要开的太小
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX=150000;
const LL INF= 100000000000000;
int a[MAX];
int main()
{
int n;
cin>>n;
while(n--){
LL res=0;
int t;
cin>>t;
if(t==0){
cout<<"0"<<endl;
continue;
}
for(int i=0;i<t;i++){
cin>>a[i];
}
for(int i=1;i<t;i++){//i为几个数一组
if(t%i==0){
LL ma=0,mi=INF,sum=0;
int x=t/i;//x为有几个组
for(int j=0;j<x;j++){
sum=0;
for(int k=0;k<i;k++){
sum+=a[j*i+k];
}
ma=max(ma,sum);
mi=min(mi,sum);
}
res=max(res,ma-mi);
}
}
cout<<res<<"\n";
}
}
C. Yarik and Array
如果前面的和<0就没有必要加前面的数,直接后面相加即可
#include <bits/stdc++.h>
using namespace std;
const int MAX=2e5+10;
int a[MAX];
int main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
memset(a,0,sizeof(a));
for(int i=1;i<=n;i++){
cin>>a[i];
}
int res=a[1],sum=a[1];
for(int i=2;i<=n;i++){
sum=max(sum,0);
if(abs(a[i]+a[i-1])%2==0) sum=0;
sum+=a[i];
res=max(sum,res);
}
cout<<res<<"\n";
}
}
D. Yarik and Musical Notes
$$
要求2 ^{a_i ^ {2 ^ {a_j}}} == 2 ^{a_j ^ {2 ^ {a_i}}} 令b_i=2{a_i}则只需要满足b_ib_j^{b_i} 对该公式进行变形就可以得到b_j*a_ia_j*b_i
$$
$$
即可得a^{j-i}==a_j/a_i有两种情况满足上式,即当a_i=a_j时满足或者a_j=2;a_i=1满足上式
$$
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX=2e5+10;
int a[MAX];
int main()
{
int t;
cin>>t;
while(t--){
map<int,LL> mp;
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
mp[a[i]]++;
}
LL res=0;
for(auto &[k,v]:mp){
res+=(v-1)*v/2;
}
res+=mp[1]*mp[2];
cout<<res<<"\n";
}
}
E. Queue Sort
大概题意有两种操作
1.将数组的第一个元素插入到末尾
2.将该元素与前一个元素交换,直到它成为第一个元素或严格大于前一个元素。
如果最小值后面的数是无序的那么我们就需要同时进行1,2两个操作,相当于数组依然没变
#include <bits/stdc++.h>
using namespace std;
const int MAX=2e5+10;
int a[MAX];
int main()
{
int m;
cin>>m;
while(m--){
int n,t=1;
cin>>n>>a[1];
int mi=a[1];
for(int i=2;i<=n;i++){
cin>>a[i];
if(a[i]<mi){
mi=a[i];
t=i;
}
}
int x=true;
for(int i=t+1;i<n;i++){
if(a[i]>a[i+1]){
cout<<"-1"<<endl;
x=false;
break;
}
}
if(x) cout<<t-1<<endl;
}
}
Codeforces Round 909 (Div3)(本菜鸟只补到了E)的更多相关文章
- 【赛时总结】◇赛时·V◇ Codeforces Round #486 Div3
◇赛时·V◇ Codeforces Round #486 Div3 又是一场历史悠久的比赛,老师拉着我回来考古了……为了不抢了后面一些同学的排名,我没有做A题 ◆ 题目&解析 [B题]Subs ...
- CODEFORCES ROUND#624 DIV3
这次比赛从名字就可以看出非常水,然鹅因为第一次打codeforces不太熟悉操作只来的及做签到题(还错了一次) A,B,C都是签到题考点思维就不写了 D题 https://codeforces.ml/ ...
- CodeForces Round #527 (Div3) B. Teams Forming
http://codeforces.com/contest/1092/problem/B There are nn students in a university. The number of st ...
- CodeForces Round#480 div3 第2场
这次div3比上次多一道, 也加了半小时, 说区分不出1600以上的水平.(我也不清楚). A. Remove Duplicates 题意:给你一个数组,删除这个数组中相同的元素, 并且保留右边的元素 ...
- CodeForces Round #527 (Div3) D2. Great Vova Wall (Version 2)
http://codeforces.com/contest/1092/problem/D2 Vova's family is building the Great Vova Wall (named b ...
- CodeForces Round #527 (Div3) D1. Great Vova Wall (Version 1)
http://codeforces.com/contest/1092/problem/D1 Vova's family is building the Great Vova Wall (named b ...
- CodeForces Round #527 (Div3) C. Prefixes and Suffixes
http://codeforces.com/contest/1092/problem/C Ivan wants to play a game with you. He picked some stri ...
- CodeForces Round #527 (Div3) A. Uniform String
http://codeforces.com/contest/1092/problem/A You are given two integers nn and kk. Your task is to c ...
- Educational Codeforces Round 78 (Rated for Div. 2) --补题
链接 直接用数组记录每个字母的个数即可 #include<bits/stdc++.h> using namespace std; int a[26] = {0}; int b[26] = ...
- Educational Codeforces Round 74 (Rated for Div. 2)补题
慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ∅ ∅ //√,×,∅ 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x> ...
随机推荐
- Ceres简单应用-求解(Powell's Function)鲍威尔函数最小值
Ceres 求解 Powell's function 的最小化 \(\quad\)现在考虑一个稍微复杂一点的例子-鲍威尔函数的最小化. \(\quad{}\) \(x=[x_1,x_2,x_3,x_4 ...
- Azure Terraform(十四)Azure Key Vault 的机密管理
一,引言 最近有网友私信我,将 Terraform 部署到 Azure 是一种将基础结构作为代码进行管理的好方法,但是如何使用 Azure Key Vault 来存储我们的 Secret ?在这篇博文 ...
- 利用msfvenom生成木马
msfvenom命令行选项如下: 英文原版: 中文版: Options: -p, --payload <payload> 指定需要使用的payload(攻击荷载).如果需要使用自定义的pa ...
- ubuntu20.4操作指令合集
每个指令前面尽量加上sudo,避免麻烦的权限问题 下载软件:sudo apt install 包名 开启/关闭防火墙(开启/关闭所有端口):sudo ufw enable/disable 防火墙状态: ...
- [PWN之路]堆攻击那些事儿
原文:https://www.freebuf.com/articles/endpoint/371095.html 0x00 前言 根据某大佬所说,pwn之路分为栈,堆,和内核.当前,如果你看到这个文章 ...
- AT_agc064_a题解
题面 题目大意 给定一个正整数 \(N\),要求构造一个序列.对于每一个在 \(1\) 到 \(N\) 之间的整数 \(i\),序列中包含了 \(i\) 个,并且将该序列首尾相接拼成环后,相邻两项之差 ...
- 03.前后端分离中台框架 zhontai 项目代码生成器的使用
zhontai 项目 基于 .Net7.x + Vue 等技术的前后端分离后台权限管理系统,想你所想的开发理念,希望减少工作量,帮助大家实现快速开发 后端地址:https://github.com/z ...
- SpringBoot - 自定义starter
目录 一.什么是SpringBoot starter机制 二.为什么要自定义starter 三.什么时候需要创建自定义starter 四.自动加载核心注解说明 五.自定义starter的开发流程 案例 ...
- Facade Pattern and Encapsulation—— Structure Class
如果只看代码的话,应该可以说Facade pattern(门面设计模式)是一种最简单的代码结构,不就封装吗!这玩意谁不会! 还是看它背后所蕴含的思想吧,看了之后发现背后的思想也很简单,非常好理解. - ...
- 数据可视化【原创】vue+arcgis+threejs 实现立体光圈闪烁效果
本文适合对vue,arcgis4.x,threejs,ES6较熟悉的人群食用. 效果图: 素材: 主要思路: 先用arcgis externalRenderers封装了一个ExternalRender ...