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> ...
随机推荐
- [selenium]浏览器基本操作
前言 版本: python:3.9 selenium:4.1.5 浏览器:firefox 创建浏览器对象 from selenium import webdriver driver = webdriv ...
- 优化nginx参数(基本通用参数)
全局域配置参数 worker_processes auto; worker_cpu_affinity auto; worker_rlimit_nofile 65530; 前两个参数用于开启nginx多 ...
- 【动画进阶】神奇的 3D 磨砂玻璃透视效果
最近,群友分享了一个很有意思的效果: 原效果的网址:frosted-glass.该效果的几个核心点: 毛玻璃磨砂效果 卡片的 3D 旋转跟随效果 整体透明度和磨砂感.以及卡片的 3D 形态会随着用户移 ...
- .NET5从零基础到精通:全面掌握.NET5开发技能【第二章】
章节: 第一章:https://www.cnblogs.com/kimiliucn/p/17613434.html 第二章:https://www.cnblogs.com/kimiliucn/p/17 ...
- BUUCTF-RE-[BJDCTF2020]BJD hamburger competition
啊这,点进去康康 dnspy反编译的题,https://www.52pojie.cn/thread-495115-1-1.html 里面有详细介绍 然后文件很多,我不知道找哪一个下手 看其他师傅的wp ...
- [ABC143E] Travel by Car
2023-02-20 题目 题目传送门 翻译 翻译 难度&重要性(1~10):4.5 题目来源 AtCoder 题目算法 最短路 解题思路 我们枚举每一对点 \((u_i,v_i)\) 间的距 ...
- 一个超经典 WinForm 卡死问题的最后一次反思
一:背景 1. 讲故事 在我分析的 200+ dump 中,同样会遵循着 28原则,总有那些经典问题总是反复的出现,有很多的朋友就是看了这篇 一个超经典 WinForm 卡死问题的再反思 找到我,说 ...
- python 运行环境变为 pytest in (for) xxx.py原因
因为本人的自定义函数名称开头为test,在.py文件内我用了unittest框架,所以环境随着变化了. 修改回去很简单,只要不使用test开头或者换个文件夹.
- 《SQL与数据库基础》23. 读写分离
目录 读写分离 一主一从 准备 配置 双主双从 准备 配置 主库配置 从库配置 从库关联主库 主库相互复制 双主双从读写分离 本文以 MySQL 为例.以 MyCat 数据库中间件为例,通过 MyCa ...
- Codeforces 1257E - The Contest
题意 三个人,每个人有一些数字,组合起来是\(1\)-\(n\),每个人可以给另一个人一个拥有的数字,问最小操作数,使得第一个人拥有\(1\)-\(i\)的数,第二个人拥有\(i+1\)-\(j\)的 ...