Codeforces Round #330 (Div. 2) (595A,595B(容斥原理))

Codeforces Round #869(Div.2) A + B 你作为主席可以提前知道所有人的观点,你可以开除出了自己在内的任何一位成员,以保证表决完k个议题时剩下的人数最多。其实综上来看,每一种情况下,不管是任何一种情况,当前与主席意见不一致的人都被开除,因此只要某人在任何一个议题上与主席的观点不一致,就会被开除,故剩下的人数最大值只能是自始至终都与主席观点一致的成员,我们只需要统计这些成员的人数即可。之间的数字之和一定和原序列相等,这点通过观察容易得出,因此转化为原序列的情况,而原序列成立已经证明,因此这种构造方式是满足所有情况的。,找出任意一个序列,其中。 阅读详情

Vitaly and Night

题目链接:

http://codeforces.com/problemset/problem/595/A

解题思路:

It was easy realization problem. Let's increase the variable i from 1 to n, and inside let's increase the variable j from 1 to 2·m. On every iteration we will increase the variable j on 2. If on current iteration a[i][j] = '1' or a[i][j + 1] = '1' let's increase the answer on one.

Asymptotic behavior of this solution — O(nm).

题目大意:

有n层楼, 每层有2 * m个窗户, 每家有2个窗户, 任何一个窗户亮说明这家还未休息, 问你有几家没有休息。

AC代码:

#include <iostream>
#include <cstdio>
using namespace std;

int main(){
    int n,m;
    while(~scanf("%d%d",&n,&m)){
        int x,cnt = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                int flag = 0;
                for(int k = 0; k < 2; k++){
                    scanf("%d",&x);
                    if(x == 1)
                        flag = 1;
                }
                if(flag)
                    cnt++;
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Pasha and Phone

题目链接:

http://codeforces.com/problemset/problem/595/B

解题思路:

Let's calculate the answer to every block separately from each other and multiply the answer to the previous blocks to the answer for current block.

For the block with length equals to k we can calculate the answer in the following way. Let for this block the number must be divided on xand must not starts with digit y. Then the answer for this block — the number of numbers containing exactly k digits and which divisible byx, subtract the number of numbers which have the first digit equals to y and containing exactly k digits and plus the number of numbers which have the first digit equals to y - 1 (only if y > 0) and containing exactly k digits.

Asymptotic behavior of this solution — O(n / k).

题目大意:

给出你n / k个a[i]和n / k个b[i], 问你有多少个k位数, 使得不以b[i]开头并且可以整除a[i]。

算法思想:

数学题,,容斥定理。 求出所有情况的总数, 减去以b[i]开头的数目就为答案。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
ll num[15];
ll a[100005],b;

int main(){
    num[0] = 1;
    for(int i = 1; i <= 10; i++)
        num[i] = num[i-1]*10;
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        int sum = n/k;
        for(int i = 0; i < sum; i++)
            scanf("%lld",&a[i]);
        ll ans = 1;
        for(int i = 0; i < sum; i++){
            scanf("%lld",&b);
            ll cnt = (num[k]-1)/a[i]+1;
            ll l = b*num[k-1],r = (b+1)*num[k-1]-1;
            if(l == 0)
                cnt = cnt-(r/a[i]+1);
            else
                cnt = cnt -(r/a[i]-(l-1)/a[i]);
            ans = (ans*cnt)%mod;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


[Spawn service failed. Exiting] ROS2运行turtlebot3_gazebo例程卡住_报错 阅读详情

相关推荐

CentOS Stream 9中安装MySQL的详细步骤

本文详细介绍了在CentOS Stream 9系统中如何进行MySQL的在线安装、离线安装以及忘记密码的恢复操作。通过阅读本文,您将能够了解并掌握在CentOS Stream 9上安装MySQL的步骤,以及在遇到忘记密码的情况下的解决方案。

小白典的博客 7257

Codeforces Round #330 (Div. 2)(A,B,C,D,E)

Codeforces Round #330 (Div. 2)tags: CodeforcesCodeforces Round 330 Div 2 A、B、C、D、E

学无涯 1257

离线安装vue脚手架,内网安装@vue/cli

公司开发环境使用内网,无法用外网,搭建环境的时候,发现内网系统没有安装vue脚手架,我搜了很多文章,发现他们的方法对我都不适用,然后就自己摸索,最终皇天不负有心人,终于被我安装上了,一下是我内网离线安装vue/cli的方法,希望能帮助到有需要的小伙伴! 因为npm被集成在nodejs中,而安装nodejs只需要把nodejs安装包copy到内网电脑安装就行,比较简单,这里就不多做演示。 在外网电脑上,使用npm install -g xxxx命令下载好我们所需要的各个安装包,比如: npm insta

Liberty_yes的博客 1万+

Codeforces Round #659 (Div. 2)A-D题解

Codeforces Round #659 (Div. 2)A-D题解 //打牛客多校去了,CD晚点施工 //写于rating值2032/2056 这一场cf是补的,题目分布并没有按照往常的难度梯度递增。 这场是同时有div1和div2,对于div2的人来说这场如果策略得到及时跟过题人数多的题去写C的话是个上分的好机会。 A题难度为一般div2场的B B1B2题难度为一般div2场的DE CD难度对应一般div2场的DE Codeforces Round #659 (Div. 2) A题难度系数1200 一

StandNotAlone的博客 1万+

手把手教你用STM32标准库写一个能OTA升级的Bootloader(附完整代码)

本文详细介绍了如何使用STM32标准库开发支持OTA无线升级的Bootloader系统,包括Flash分区规划、Bootloader核心实现、无线升级流程及安全校验机制。通过实战代码示例,帮助开发者快速掌握STM32固件升级技术,提升物联网设备的远程维护能力。

weixin_30181209的博客 262

【NTN 卫星通信】使用地面网络和卫星网络接入的终端应用场景

卫星接入有广覆盖的特点, 可以改善地面接入网覆盖或无线条件差的地区(例如多径干扰)的服务可用性。对于高速移动中需要实时业务的终端,如IMS语音/视频会议,可以通过地面接入和卫星接入同时实现与5G系统的双连接,在地面接入网不可用的情况下获得连续可靠的业务。

weixin_43603524的博客 2558

Codeforces Round #609 (Div. 2) B. Modulo Equality

Codeforces Round #609 (Div. 2) B. Modulo Equality You are given a positive integer m and two integer sequence: a=[a1,a2,…,an] and b=[b1,b2,…,bn]. Both of these sequence have a length n. Permutation is...

旺崽的博客 3052

VC Spyglass实战指南:从零开始掌握CDC约束配置与调试

本文详细介绍了如何使用VC Spyglass进行CDC约束配置与调试,从基础环境搭建到典型CDC问题调试实战,帮助开发者快速掌握跨时钟域验证技术。通过TCL脚本和SDC约束的深度解析,提升CDC验证效率,避免常见设计风险。

weixin_26757925的博客 294

Codeforces Round #646 (Div. 2) B. Subsequence Hate

Codeforces Round #646 (Div. 2) B. Subsequence Hate 题目链接 Shubham has a binary string s. A binary string is a string containing only characters “0” and “1”. He can perform the following operation on the string any amount of times: Select an index of the stri

旺崽的博客 2573

当勒索软件盯上虚拟化层:从CVE-2025-22225漏洞看ESXi安全加固要点

本文深度剖析了针对VMware ESXi虚拟化层的CVE-2025-22225等漏洞链的攻击原理,揭示了攻击者如何利用VMCI、HGFS组件从虚拟机逃逸至宿主机。文章从实战角度出发,系统性地提出了ESXi安全加固的核心策略,包括禁用非必要服务、强化主机配置、实施网络分段、建立实时监控与自动化补丁管理体系,为企业构建纵深防御体系提供了具体可行的操作指南。

terraform7cloud的博客 853

如何在飞腾平台上安装Ubuntu操作系统

注意: 若主板上配置的是NVME硬盘,在进行内核配置时,需要将内核的NEME驱动勾选上,否则移植内核时,无法找到文件系统,进不去操作系统。可以通过rufus软件将镜像做到U盘中,本次使用版本为Rufus 3.9.124 ,其他版本也可以。不要下载live版本的,没有准备网络环境,是一个头疼的事情,笔者暂时没有实现网络安装。将U盘接到主板usb口上,接上串口,显示器,,必需串口有打印才可以安装。可以通过dd命令,将iso安装到U盘。安装的是最小系统,缺少很多命令,需要联网更新,或则更换飞腾专用内核。

技术联盟 2641

Codeforces Round #632 (Div. 2) B.Kind Anton

Codeforces Round #632 (Div. 2) B.Kind Anton 题目链接 Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem: There are two arrays of integers a ...

旺崽的博客 2512

DataCastle-租金预测

ID:编号;时间:房屋信息采集的时间;小区名:房屋所在小区,已脱敏处理;小区房屋出租数量:小区出租房屋数量,已脱敏处理;楼层:0、1、2分别表示楼层低,中,高;总层数:房屋所在建筑的总楼层数,已脱敏处理;房屋面积:房屋面积数值,已脱敏处理;房屋朝向:房屋的朝向;居住状态:房屋的居住状态,表示是否已出租或居住中,已脱敏处理;卧室数量:户型信息,数字表示卧室的个数;卫的数量:户型信息,数字表示卫生间的个数;厅的数量:户型信息,数字表示厅的个数;

优快云 精品推荐 3457

Codeforces Round #595 (Div. 3) - BenFromHRBUST

Codeforces Round #595 (Div. 3) 比赛传送门 A - Yet Another Dividing into Teams Code #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,a,b) for(int i=(a);i<=(b)...

BenFromHRBUST的优快云博客 215

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Codeforces Round #328 (Div. 2)(A B C D)

codeforces round #328 (div. 2)

学无涯 1952

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Codeforces Round #660 (Div. 2)A-D题解

Codeforces Round #660 (Div. 2)A-D题解 //写于rating值2184/2184 //上黄场,rating值+152。这一场没有什么算法,靠着一波快手速抢了一波不计div1选手的div2的第25名,记div1选手的第109名。很侥幸,但是上了黄名还是非常开心的。 比赛链接:https://codeforces.ml/contest/1388 A题 简单的构造。应该有很多的过题方法,这里我用的特判的方法,在稿纸上列了一波,6分钟过的题。 给定一个数字n,我们需要构造四个正整数a

StandNotAlone的博客 2231

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Codeforces Round #327 (div.2)(A B C D)

codeforces round #327 (div.2)

学无涯 1730

Codeforces Round #639 (Div. 2)(A,B,C,D,E)

@[TOC](Codeforces Round #639 (Div. 2)) A. Puzzle Pieces 思路: 规律题, 横列有一个值为1,另一个是多少都是合法的 行列的最小值为2的时候,行列的最大值必须也等于2才行, 其他情况都是非法的 代码: #include <bits/stdc++.h> using namespace std; #define pb push_ba...

亦申的博客 1077

Codeforces Round #619 (Div. 2) B.Motarack's Birthday

Codeforces Round #619 (Div. 2) B.Motarack’s Birthday Dark is going to attend Motarack’s birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers. D...

旺崽的博客 3107

Codeforces Round #639 (Div. 2) A.Puzzle Pieces

Codeforces Round #639 (Div. 2) A.Puzzle Pieces You are given a special jigsaw puzzle consisting of n⋅m identical pieces. Every piece has three tabs and one blank, as pictured below. The jigsaw puzzle ...

旺崽的博客 2593

Codeforces Round #619 (Div. 2)

Codeforces Round #619 (Div. 2) A题: 题解: 开始没看懂,后来发现c和a,b交换的操作是强制的。那么就很白给了。 #include <bits/stdc++.h> //#define int long long using namespace std; const int N=1e5+7; int t, n, a[N]; int main() { ...

行走天涯的豆沙包的博客 254

Codeforces Rounds #254 div2:A,B,C

7.6日2014 codeforces round #254

chinnmt的专栏 866

Codeforces Round #247 (Div. 2) ABC

Codeforces Round #247 (Div. 2)

水果君の日常 2090

Codeforces Round #306 (Div. 2)

题目传送:Codeforces Round #306 (Div. 2) 这次打的很差,有点累,先贴个代码吧。。 A - Two Substrings #include #include #include #include #include #include #include #include #include #include #include #i

Never say never 848

Codeforces Round #662 (Div. 2)A-D题解

Codeforces Round #662 (Div. 2)A-D题解 //写于大号rating值2184/2184,小号rating值1881/1881 //本场拿小号打的,名次在div2选手排78,rating值+219 //A白交了一发假结论,D写错两个变量下标白给两发… //人永远也不能做到不犯低级错误,只能尽可能避免… 比赛链接:https://codeforces.com/contest/1393 A题 过题用时:5min(罚时1发) 简单结论 具体就不解释了,我的思考方式是从n为奇数开始考虑。

StandNotAlone的博客 1563

Codeforces Round #630 (Div. 2)

Codeforces Round #630 Div. 2ABCDEF A 题意:给定一个范围(x1,y1),(x2,y2)、猫的初始位置(x,y)、猫走的方向和步数a:左,b:右,c:下,d:上,判断猫走完之后能否在这个范围内。 题记:判断初始位置到边界的距离是否小于向这个边界走的步数即可,最后要特判一下初始位置和边界重复的情况。 #include<bits/stdc++.h> us...

moyangxian 1205
上一篇: Codeforces Round #329 (Div. 2) (593A,593B,593C,593D)
下一篇: Testing Round #12 (597A,597B,597C)
yphacker
博客等级 码龄12年 199粉丝 540原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值