目录

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. 史上最全Redis面试题(2020最新版)

    一个执着于技术的公众号 导读:2020 年最新版 Redis面试题,两万字干货,为方便读者阅读,已整理为PDF文档,后台回复『redis』即可领取.希望对大家有帮助! 概述 1. 什么是Redis? ...

  2. 干货 | 一文彻底读懂nginx中的location指令

    一个执着于技术的公众号 Nginx系列导读 给小白的 Nginx 10分钟入门指南 Nginx编译安装及常用命令 完全卸载nginx的详细步骤 Nginx 配置文件详解 一文带你读懂Nginx反向代理 ...

  3. 百度SEO算法技术的局限性,怎么做才能有收益

    不知道大家有没有发现,我们使用百度的频率在减少,就算有时遇到一些问题,需要用百度来寻找答案,也会经常遇到搜索不到答案的情况.到底是出了什么问题?难道网络上的资源不够丰富了?浩如烟海的互联网,居然搜索不 ...

  4. Next.js 在 Serverless 中从踩坑到破茧重生

    作者 杨苏博,偏后端的全栈开发,目前负责腾云扣钉的 Cloud Studio 产品.在团队中负责接技术架构设计与 Review.Cloud Studio 编辑器内核设计与开发.部分核心插件设计与开发: ...

  5. 设计模式---单例模式,pickle模块

    设计模式---单例模式 简介 单例模式(Singleton Pattern) 是一种常用的软件设计模式,该模式的主要目的是确保某一个类只有一个实 例存在.当你希望在整个系统中,某个类只能出现一个实例时 ...

  6. 【java并发编程】ReentrantLock 可重入读写锁

    目录 一.ReentrantLock可重入锁 二.ReentrantReadWriteLock读写锁 三.读锁之间不互斥 欢迎关注我的博客,更多精品知识合集 一.ReentrantLock可重入锁 可 ...

  7. Vulnhub-earth

    1.信息收集 1.1找到目标主机ip vulnhub靶场通用的技巧 这里我们靶场是nat模式的 所以肯定就是在我们自己设置的一个网段范围内,我这里nat本机的地址是10.1.1.1 所处的网段就是10 ...

  8. Sqoop导入数据到mysql数据库报错:ERROR tool.ExportTool: Error during export: Export job failed!(已解决)

    问题描述: Container killed by the ApplicationMaster. Container killed on request. Exit code is 143 Conta ...

  9. 将汇总结果导出到MySQL

    ①mysql建表test1 ②cd /opt/module/sqoop进入scoop路径 ③ bin/sqoop export \ > --connect jdbc:mysql://master ...

  10. 深入解读SQL的聚集函数

    摘要:本文从基本聚集操作入手,介绍常用的SQL语法,以及一些扩展的聚集功能,同时会讲到在GaussDB(DWS)里聚集相关的一些优化思路. 本文分享自华为云社区<GaussDB(DWS) SQL ...