目录

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. 用 Docker 快速搭建 Kafka 集群

    开源Linux 一个执着于技术的公众号 版本 •JDK 14•Zookeeper•Kafka 安装 Zookeeper 和 Kafka Kafka 依赖 Zookeeper,所以我们需要在安装 Kaf ...

  2. python牛顿法求一元多次函数极值

    现在用牛顿法来实现一元函数求极值问题 首先给出这样一个问题,如果有这么一个函数$f(x) = x^6+x$,那么如何求这个函数的极值点 先在jupyter上简单画个图形 %matplotlib inl ...

  3. hive从入门到放弃(六)——常用文件存储格式

    hive 存储格式有很多,但常用的一般是 TextFile.ORC.Parquet 格式,在我们单位最多的也是这三种 hive 默认的文件存储格式是 TextFile. 除 TextFile 外的其他 ...

  4. SQL中把汉字转换拼音码

    思路:在SQL中创建一个函数fn_GetPy(),函数的输入参数是一个汉字字符串,返回值是拼音码字符串. 创建函数语句: CREATE function fn_GetPy(@str nvarchar( ...

  5. 3D编程模式:依赖隔离模式

    大家好~本文提出了"依赖隔离"模式 系列文章详见: 3D编程模式:开篇 本文相关代码在这里: 相关代码 目录 编辑器需要替换引擎 设计意图 定义 应用 扩展 最佳实践 更多资料推荐 ...

  6. CSRF跨站请求伪造与XSS跨域脚本攻击讨论

    今天和朋友讨论网站安全问题,聊到了csrf和xss,刚开始对两者不是神明白,经过查阅与讨论,整理了如下资料,与大家分享. CSRF(Cross-site request forgery):跨站请求伪造 ...

  7. Go写文件的权限 WriteFile(filename, data, 0644)?

    本文来自博客园,作者:阿伟的博客,转载请注明原文链接:https://www.cnblogs.com/cenjw/p/go-ioutil-writefile-perm.html 前言 go iouit ...

  8. 基恩士的浓淡补正算法(Shading Correction Filter)的模拟实现。

    知道这个算法应该有很久了,主要当时在意2个事情,一个是这个名字的翻译是在是搞笑,第二是这个算法的效果.不过一直以来都十分好奇这个算法是怎么实现的.因为之前一直无法实际的用基恩士的软件平台用不同的图片去 ...

  9. SAP APO-供需匹配

    供需匹配包含主要功能"匹配能力"(CTM)和一个用于分配库存的附加功能. 在高级计划和优化中,SDM组件为这些应用程序提供跨工厂供应策略- 生产计划和详细计划(PP / DS) 供 ...

  10. SE37 绕过权限检查 ALINK_CALL_TRANSACTION