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)的更多相关文章

  1. 【赛时总结】◇赛时·V◇ Codeforces Round #486 Div3

    ◇赛时·V◇ Codeforces Round #486 Div3 又是一场历史悠久的比赛,老师拉着我回来考古了……为了不抢了后面一些同学的排名,我没有做A题 ◆ 题目&解析 [B题]Subs ...

  2. CODEFORCES ROUND#624 DIV3

    这次比赛从名字就可以看出非常水,然鹅因为第一次打codeforces不太熟悉操作只来的及做签到题(还错了一次) A,B,C都是签到题考点思维就不写了 D题 https://codeforces.ml/ ...

  3. 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 ...

  4. CodeForces Round#480 div3 第2场

    这次div3比上次多一道, 也加了半小时, 说区分不出1600以上的水平.(我也不清楚). A. Remove Duplicates 题意:给你一个数组,删除这个数组中相同的元素, 并且保留右边的元素 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. Educational Codeforces Round 78 (Rated for Div. 2) --补题

    链接 直接用数组记录每个字母的个数即可 #include<bits/stdc++.h> using namespace std; int a[26] = {0}; int b[26] = ...

  10. Educational Codeforces Round 74 (Rated for Div. 2)补题

    慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ∅ ∅ //√,×,∅ 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x> ...

随机推荐

  1. centos7离线安装harbor

    前言 harbor是一个docker私有仓库,基于docker官方的registry,提供GUI.权限控制.项目管理等功能. 安装harbor前,需要先安装docker和docker-compose ...

  2. jmeter:内存溢出解决办法

    使用jmeter执行性能测试,报错:java.lang.OutOfMemoryError: Java heap space 需要对jmeter的jvm进行调优.记录如下: 1. 问题记录及分析: 使用 ...

  3. 小版本更新kubernetes

    小版本更新kubernetes 背景 最近一段时间躺平了没有更新我的博客文档.感谢各位小伙伴一直以来的支持. 此脚本基于 https://github.com/cby-chen/Kubernetes/ ...

  4. 论文解读(TAT)《 Transferable Adversarial Training: A General Approach to Adapting Deep Classifiers》

    Note:[ wechat:Y466551 | 可加勿骚扰,付费咨询 ] 论文信息 论文标题:Transferable Adversarial Training: A General Approach ...

  5. 【路由器】OpenWrt 手动编译 ipk

    目录 .ipk 文件 编译准备 编译 .ipk 文件 更新 feeds 配置平台 获取交叉编译链 添加需要编译的第三方软件包 参考资料 .ipk 文件 .ipk 文件是可以通过 OpenWrt 的包管 ...

  6. ORM查询一个表中有两个字段相同时,只获取某个值最大的一条

    Table表如下: 获取表中name和hex值相同时age最大的那一条 ORM写法,两次查询 ids = table.values('name', 'age').annotate(id=Max('id ...

  7. Empowering Long-tail Item Recommendation through Cross Decoupling Network (CDN)

    Empowering Long-tail Item Recommendation through Cross Decoupling Network (CDN) 来源: KDD'2023 Google ...

  8. 关于前后端交互,取header的尴尬

    背景: 最近在写一个接口的时候,需求是这样的,上传excel,匹配项目有多少个字段匹配上了,如果匹配上了在单元格上标注绿色背景,然后返回excel文件和匹配的详细. 首先这个excel文件,后端是不会 ...

  9. 升讯威在线客服系统的并发高性能数据处理技术:PLINQ并行查询技术

    我在业余时间开发维护了一款免费开源的升讯威在线客服系统,也收获了许多用户.对我来说,只要能获得用户的认可,就是我最大的动力. 最近客服系统成功经受住了客户现场组织的压力测试,获得了客户的认可. 客户组 ...

  10. Ds100p -「数据结构百题」1~10

    1.「一本通 4.6 例 1」营业额统计 原题来自:HNOI 2002 Tiger 最近被公司升任为营业部经理,他上任后接受公司交给的第一项任务便是统计并分析公司成立以来的营业情况. Tiger 拿出 ...