目录

A:

B:

C:


题目链接

A

Divide and Multiply

standard input/output

1 s, 256 MB

正在上传…重新上传取消 x13036
B

William the Vigilant

standard input/output

2 s, 256 MB

正在上传…重新上传取消 x10007
C

Complex Market Analysis

standard input/output

2 s, 256 MB

正在上传…重新上传取消 x7544

A:

这道题目使用了一个数学知识,使得可以更加快速地求出最后一位1后的0的个数

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll H[37];
ll a[20];
ll b[20];//0的数目
ll c[20];
ll num;
void Init()
{
for(int i = 0; i <= 31; i++)
{
H[(1ll << i) % 37] = i;
}
}
void solve()
{
c[0] = 0;
for(int i = 1; i <= num; i++)
{
b[i] = H[(a[i] & (-a[i]) )%37];
}
for(int i = 1; i <= num; i++)
{
c[i] = a[i] >> b[i];
}
int maxpos = 0;
for(int i = 1; i <= num; i++)
{
if(c[i] >= c[maxpos])
maxpos = i;
}
for(int i = 1; i <= num; i++)
{
if(i != maxpos)
{
a[i] >>= b[i];
a[maxpos] <<= b[i];
}
}
ll ans = 0;
for(int i = 1; i <= num; i++)
{
ans += a[i];
}
printf("%lld\n", ans);
}
int main()
{
Init();
int T;
cin >> T;
while(T--)
{ scanf("%lld", &num);
for(int i = 1; i <= num; i++)
scanf("%lld", a+i);
solve();
} return 0;
}

B:

注意子序列与子串的区别

#include <bits/stdc++.h>
using namespace std;
char s[100007];
int n, q;
bool sub(int pos)
{
switch (s[pos])
{
case 'a':
if(pos+2 > n)
return false;
if(s[pos+1] == 'b' && s[pos+2] == 'c') return true;
else return false;
break;
case 'b':
if(pos + 1 > n || pos-1 < 1) return false;
if(s[pos-1]=='a' && s[pos+1]=='c') return true;
else return false;
break;
case 'c':
if(pos-2 < 1) return false;
if(s[pos-2]=='a' && s[pos-1]=='b') return true;
else return false; break;
}
return false;
}
int main()
{
int cnt = 0;
scanf("%d%d", &n, &q);
scanf("%s", s+1);
for(int i = 1; i <= n-2; i++) if(s[i]=='a'&&s[i+1]=='b'&&s[i+2]=='c') cnt++;
while(q--)
{
int pos;
char buf[10];
scanf("%d%s",&pos, buf);
if(sub(pos)) cnt--;
s[pos] = buf[0];
if(sub(pos)) cnt++;
printf("%d\n", cnt);
}
}

C:

#include <bits/stdc++.h>
using namespace std;
#define MAX 1000007
typedef long long ll;
bitset<MAX>notprime;
int prime[MAX];
void Init()
{
int k = 0;
notprime[0] = true;
notprime[1] = true;
for(int i = 2; i <= 1000005; i++)
{
if(!notprime.test(i))
prime[++k] = i;
for(int j = 1; j <= k; j++)
{
if(prime[j] * i > 1000005) break;
notprime[prime[j] * i] = true;
if(i % prime[j]==0) break;
}
}
}
int s[MAX];
int n, e;
inline int next(int x)
{
return x+e;
}
inline int before(int x)
{
return x-e;
}
inline int dis(int x, int y)
{
return abs(x-y) / e;
}
/*
int main()
{
Init();
for(int i = 1; i <= 100; i++) printf("%d\t", prime[i]);
return 0;
}
*/
//欧拉筛写错了,导致出了大问题。
int main()
{
Init();
int T;
cin >> T;
while(T--)
{
ll ans = 0;
scanf("%d%d", &n, &e);
for(int i = 1; i <= n; i++)
{
scanf("%d", s+i);
}
for(int i = 1; i <= e; i++)
{
int p = i;
while(p <= n)
{
if(!notprime.test(s[p]))
{
int l = before(p);
int r = next(p);
while(l >= 1 && s[l] == 1) l = before(l);
while(r <= n && s[r] == 1) r = next(r);
ans += (ll)dis(p, l) * dis(r, p) - 1;
}
p = next(p);
}
}
printf("%lld\n", ans);
}
return 0;
}

CodeForce——Deltix Round, Autumn 2021 (open for everyone, rated, Div. 1 + Div. 2)前三道题目题解的更多相关文章

  1. CF Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)

    1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort    暴力枚举,水 1.题意:n*m的数组, ...

  2. Codeforces 1023 A.Single Wildcard Pattern Matching-匹配字符 (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)

    Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A. Single Wildcard Patter ...

  3. Codeforces Round #438 (Div.1+Div.2) 总结

    本来兴致勃勃的想乘着这一次上紫,于是很早很早的到了机房 但是好像并没有什么用,反而rating-=47 Codeforces Round #438(Div.1+Div.2) 今天就这样匆匆的总结一下, ...

  4. Codeforces Round #524 (Div. 2)(前三题题解)

    这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...

  5. Educational Codeforces Round 53 (Rated for Div. 2) (前五题题解)

    这场比赛没有打,后来补了一下,第五题数位dp好不容易才搞出来(我太菜啊). 比赛传送门:http://codeforces.com/contest/1073 A. Diverse Substring ...

  6. Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) (前三题题解)

    这场比赛好毒瘤哇,看第四题好像是中国人出的,怕不是dllxl出的. 第四道什么鬼,互动题不说,花了四十五分钟看懂题目,都想砸电脑了.然后发现不会,互动题从来没做过. 不过这次新号上蓝名了(我才不告诉你 ...

  7. Codeforces Round #519 by Botan Investments(前五题题解)

    开个新号打打codeforces(以前那号玩废了),结果就遇到了这么难一套.touristD题用了map,被卡掉了(其实是对cf的评测机过分自信),G题没过, 700多行代码,码力惊人.关键是这次to ...

  8. Codeforces Round #609 (Div. 2)前五题题解

    Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...

  9. Codeforces Round #792 (Div. 1 + Div. 2) A-E

    Codeforces Round #792 (Div. 1 + Div. 2) A-E A 题目 https://codeforces.com/contest/1684/problem/A 题解 思路 ...

随机推荐

  1. 字符编码,存储引擎,MySQL字段类型,MySQL字段约束条件

    字符编码 查看MySQL默认编码命令:\s """ 如果是5.X系列 显示的编码有多种 latin1 gbk 如果是8.X系列 显示的统一是utf8mb4 utf8mb4 ...

  2. 1.0 vue开篇之作

    vue官网链接:https://cn.vuejs.org/ 一. vue简介 vue目前分为2.X版和3.X版,本文以2.X版为准,后续会更新3.X版本相关教程,建议从2.X版开始学起,因为此版本经过 ...

  3. arts-week9

    Algorithm 521. Longest Uncommon Subsequence I - LeetCode Review 如何搭建一个私有的CDN? 大部分情况下,我们使用市场上现有的 CDN ...

  4. 04 Springboot 格式化LocalDateTime

    Springboot 格式化LocalDateTime 我们知道在springboot中有默认的json解析器,Spring Boot 中默认使用的 Json 解析技术框架是 jackson.我们点开 ...

  5. Nanodet模型部署(ncnn,openvino)/YOLOX部署(TensorRT)

    Nanodet模型部署(ncnn,openvino) nanodet官方代码库nanodet 1. nanodet模型部署在openvino上 step1: 参考链接 nanodet官方demo op ...

  6. 关于『进击的Markdown』:第一弹

    关于『进击的Markdown』:第一弹 建议缩放90%食用 比起隐蔽物下的狙击手,Markdown更像冲锋陷阵的阵头兵 简单.粗暴.直接.而且好上手 各位晚上好! 早饭吃了吗您 我 今 天 没 吃 M ...

  7. 白嫖Azure与体验GoLand远程开发

    前言 近期因为有本地开发远程使用Linux编译部署的需求,而虚拟机的性能实在是不敢恭维,WSL的坑之前也踩过(没有systemd等),故考虑使用SSH连接云服务器开发. 目前VSCode提出了Remo ...

  8. GitHub 简介

    用详细的图文对GitHub进行简单的介绍. git是一个版本控制工具,github是一个用git做版本控制的项目托管平台. 主页介绍: overview:总览.相当于个人主页. repositorie ...

  9. Sec资产管理——SwebUI开源应用解决方案

    产品简介 Sweb Sec是一款资产管理类的开源解决方案,通过SwebUI平台开发,包含资产管理.耗材管理两种管理系统,由部门管理.区域管理.盘点.标签打印.出入库等核心功能组成. 免费获取方案 开源 ...

  10. 如何写一个全局的 Notice 组件?

    下面将会实现这样的效果: 组件动态创建脚本: NotificationBanner.js import Vue from "vue"; import Notice from &qu ...