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> ...
随机推荐
- 新一代开源流数据湖平台Apache Paimon入门实操-下
@ 目录 实战 写表 插入和覆盖数据 更新数据 删除数据 Merge Into 查询表 批量查询 时间旅行 批量增量查询 流式查询 时间旅行 ConsumerID 查询优化 系统表 表指定系统表 分区 ...
- 应用程序通过 Envoy 代理和 Jaeger 进行分布式追踪(一)
Istio 支持通过 Envoy 代理进行分布式追踪,代理自动为其应用程序生成追踪 span,只需要应用程序转发适当的请求上下文即可.Istio 支持很多追踪系统,包括 Zipkin, Jaeger, ...
- springboot jar thin
springboot jar thin springboot 应用 jar 瘦身.springboot jar 太大.jar与依赖包分离. 两种方法,第一种,spring-boot-thin-laun ...
- 《深入理解Java虚拟机》读书笔记:垃圾收集器
垃圾收集器 HotSpot虚拟机包含的所有收集器如图3-5所示.图3-5展示了7种作用于不同分代的收集器,如果两个收集器之间存在连线,就说明它们可以搭配使用. 新生代收集器:Serial.ParNew ...
- virtualbox克隆虚拟机
1.选择要克隆的虚拟机 2.设置克隆机的名称和存放位置 3.选择克隆类型 4.克隆结果
- Java stream 流
Java stream 流 中间操作 1.filter 作用:将流中的元素,基于自定义的比较器进行去重 方法定义 Stream<T> filter(Predicate<? super ...
- C++算法之旅、05 基础篇 | 第二章 数据结构
常用代码模板2--数据结构 - AcWing 笔试用数组模拟而不是结构体 使用结构体指针,new Node() 非常慢,创建10万个节点就超时了,做笔试题不会用这种方式(优化是提前初始化好数组,但这样 ...
- Htttpclien循环自动生成图片,同时发送参数和文件,模拟http的post请求
package org.jeecg.modules.bussiness.PostTests; import com.sun.tools.internal.xjc.reader.xmlschema.bi ...
- 4399 Flash游戏专用浏览器, 无需安装Flash插件
目前所有的主流浏览器都已经不再支持Flash了,即使有一些国内浏览器还支持flash,但只能安装国内特供版Flash Player. 但问题的关键在于,这个国内特供版跟 Adobe 海外发行的版本是两 ...
- Ds100p -「数据结构百题」1~10
1.「一本通 4.6 例 1」营业额统计 原题来自:HNOI 2002 Tiger 最近被公司升任为营业部经理,他上任后接受公司交给的第一项任务便是统计并分析公司成立以来的营业情况. Tiger 拿出 ...