Codeforces Round #326 (Div. 2) (588A,588B,587A)

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

1.Duff and Meat


题目链接:

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

解题思路:

Idea is a simple greedy, buy needed meat for i - th day when it's cheapest among days 1, 2, ..., n.

So, the pseudo code below will work:

ans = 0
price = infinity
for i = 1 to n
      price = min(price, p[i])
      ans += price * a[i]

Time complexity: 


AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main(){
    int n,a,p;
    while(~scanf("%d",&n)){
        ll sum = 0;
        int minp = 200;
        for(int i = 0; i < n; i++){
            scanf("%d%d",&a,&p);
            if(p < minp)
                minp = p;
            sum += a*minp;
        }
        printf("%lld\n",sum);
    }
    return 0;
}

2.Duff in Love

题目链接:

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

解题思路:

Find all prime divisors of n. Assume they are p1, p2, ..., pk (in ). If answer is a, then we know that for each 1 ≤ i ≤ k, 

obviously a is not divisible by pi2 (and all greater powers of pi). So a ≤ p1 × p2 × ... × pk. And we know that p1 × p2 × ... × pk is itself 

lovely. So,answer is p1 × p2 × ... × pk

Time complexity: 

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
int vis[1000005];
int prime[80000];
ll prime2[80000];
int nprime;

void getprime(){
    nprime = 0;
    memset(vis,0,sizeof(vis));
    for(int i = 2; i <= 1000000; i++){
        int t = 1000000/i;
        for(int j = 2; j <=t; j++)
            vis[i*j] = 1;
    }
    for(int i = 2; i <= 1000000; i++){
        if(!vis[i]){
            prime[nprime] = i;
            prime2[nprime++] = (ll)i*i;
        }
    }
}

int main(){
    getprime();
    //cout<<nprime<<endl;
    ll n;
    while(~scanf("%lld",&n)){
        for(int i = 0; i < nprime; i++){
            if(n % prime2[i] == 0){
                while(n % prime2[i] == 0)
                    n /= prime[i];
            }
        }
        printf("%lld\n",n);
    }
    return 0;
}

3.Duff in Beach


题目链接:

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

解题思路:

Problem is: you have to find the minimum number of k, such there is a sequence a1, a2, ..., ak with 

condition2a1 + 2a2 + ... + 2ak = S = 2w1 + 2w2 + ... + 2w2. Obviously, minimum value of k is the number of set bits in binary r

epresentation of S(proof is easy, you can prove it as a practice :P).

Our only problem is how to count the number of set bits in binary representation of S? Building the binary representation of S as an 

array in is easy:

算法思想:

因为后来题意有更正,更改为:

Duff may throw out an arbitrary subsequence of weights, not necessarily contiguous. The weights aren't necessarily sorted in the input.

使得题目变简单了。因为不需要连续,所以只要记录一下每个数的次数,判断奇偶即可。

AC代码:

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

int vis[1000005];

int main(){
    int n;
    while(~scanf("%d",&n)){
        memset(vis,0,sizeof(vis));
        int x;
        for(int i = 0; i < n; i++){
            scanf("%d",&x);
            vis[x]++;
        }
        int sum = 0;
        for(int i = 0; i <= 1000000; i++){
            if(vis[i]){
                if(vis[i] % 2)
                    sum++;
                vis[i+1] += vis[i] / 2;
            }
        }
        int t = vis[1000001];
        while(t){
            if(t&1)
                sum++;
            t >>= 1;
        }
        printf("%d\n",sum);
    }
    return 0;
}



深入Android构建系统:一次修改ro.vendor.build.fingerprint失败的排查与解决记录 本文深入探讨了Android构建系统中修改ro.vendor.build.fingerprint的完整解决方案。通过分析vendor分区的特殊地位和构建指纹的生成路径,提供了三种实战修改方法,并揭示了指纹修改可能遇到的陷阱与对策,帮助开发者彻底解决这一常见问题。 阅读详情

相关推荐

Flutter热更新实战:Shorebird从安装到发布补丁的完整流程(含iOS/Android差异解析)

本文详细介绍了Flutter热更新工具Shorebird的完整使用流程,包括安装、发布补丁及iOS/Android平台差异解析。Shorebird作为Flutter官方未提供的Code Push解决方案,能快速修复线上问题,支持合规性保障和性能优化,特别适合紧急修复场景。文章还涵盖了国内CDN加速配置和最佳实践,帮助开发者高效实现热更新。

butter的博客 1083

物联网设备安全认证:Atlas框架与mTLS实践

物联网设备认证是保障智能家居、智慧城市等场景安全通信的核心技术。传统基于OAuth令牌的认证方案存在云端中转延迟高、传输层缺乏加密等缺陷,而mTLS(双向TLS认证)通过X.509证书体系实现设备间端到端加密通信。Atlas框架创新性地将Web PKI体系移植到物联网领域,通过ACME协议自动化管理设备证书,支持跨厂商设备直接认证。该方案在ESP32等资源受限设备上通过ECC加速和证书裁剪优化,使mTLS握手时间从1.2秒降至170ms,内存占用减少65%。实际测试显示,Atlas在智能家居场景下将设备联动

weixin_30444105的博客 483

手把手教你用Python+GDAL处理0.5米吉林一号卫星影像(附代码)

本文详细介绍了如何使用Python和GDAL处理吉林一号0.5米高分辨率卫星影像,包括环境配置、数据预处理、分辨率融合、植被指数计算及地物分类等关键步骤。通过实战代码示例,帮助开发者高效处理大尺寸遥感数据,解决资源崩溃和算法选择问题,提升遥感影像分析能力。

weixin_30892037的博客 141

Codeforces Round #326 (div2)

1001. 题解: Idea is a simple greedy, buy needed meat for i - th day when it's cheapest among days 1, 2, ..., n. So, the pseudo code below will work: ans = 0 price = infinity for i = 1 to n

01的世界 359

STM32 Modbus-RTU从零到实战:手把手教你用HAL库实现工业通信(附完整代码)

本文详细介绍了如何使用STM32 HAL库从零开始实现Modbus-RTU从机通信。内容涵盖RS485硬件设计、CubeMX串口与定时器配置、基于空闲中断的高效数据接收、协议栈状态机设计、CRC16校验实现以及常用功能码处理。文章提供了完整的代码框架和调试方法,帮助开发者快速构建稳定的工业通信节点。

weixin_28278377的博客 201

基于4G cat.1的低功耗车牌识别摄像头模组介绍

在消费类摄像头领域,4G低功耗相机已经非常普遍,在可视门锁,婴儿看护,户外监控等领域都获得了很好的应用.但是在工业领域,低功耗相机的应用还不是那么广泛.这里要介绍一款基于4G cat.1的低功耗车牌识别摄像头模组,在待机状态只有MCU和毫米波雷达以1Hz的频率工作,功耗低至500uA,并可以通过4G模块远程唤醒模组.

bindaz的专栏 1667

CF 588B Duff in Love

B. Duff in Love time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Duff is in love with lovely numbers! A posi

浮生匆忙,与君同往 849

Jetson Orin Nano - SONY imx415 camera驱动开发

基于英伟达 Jetson orin nano 平台 imx415 camera驱动开发

hinewcc的博客 3278

Duff and Meat - CF 588A

题目大意:有一个人他有每天需要吃ai千克肉,并且当天肉的价格是pi,问N天后他至少需要花费多少钱买肉。 分析:注意一下,他是可以提前买好肉放着的。 代码如下: #include<iostream> #include<string.h> #include<stdio.h> #include<algorithm> #include&...

weixin_30735391的博客 103

什么事LLVM和Clang?Clang与GCC有什么区别?Clang如何使用?

这个问题主要讲Xcode编译器的认知,在学习iOS之前有必要学习一下Objective-C的编译环境。 在了解LLVM和Clang之前,先得了解一下什么是编译器。 编译器是一种计算机程序,它将某种编程语言(高级编程语言)写成的源代码转换成另一种编程语言(低级编程语言)。一个现代编译器的主要工作流程为:源代码->预处理器->编译器->目标代码->链接器->可执行程序...

Welcome~ 9740

智能车新手必看:如何用PID和差速转弯让小车跑得更稳(附代码示例)

本文详细介绍了智能车控制系统中PID算法和差速转弯的实现方法,包括位置式与增量式PID的选择、参数整定技巧以及编码器反馈的关键作用。通过代码示例和实战经验,帮助新手快速掌握智能车稳定行驶的核心技术,提升赛道表现。

mmm90的博客 133

很好的一个dp题目 Codeforces Round #326 (Div. 2) D dp

http://codeforces.com/contest/588/problem/D 感觉吧,这道题让我做,我应该是不会做的。。。 题目大意:给出n,L,K。表示数组的长度为n,数组b的长度为L,定义数组b[i]=a[i%n]。然后数组b的最长的lis为k,问能有几组<=k的lis 条件如下: ①序列长度>=1并且<=k ②序列在每一块长度为n的数组中只能选择一个数,...

weixin_33851604的博客 249

【Bug已解决】zsh: command not found: claude 解决方案

方案适用场景推荐指数难度方案一:配置 npm 全局目录所有平台,长期使用⭐⭐⭐⭐⭐低方案二:修复 PATH 变量快速修复,不想改 npm 配置⭐⭐⭐⭐低方案三:重建软链接文件存在但链接断裂⭐⭐⭐中方案四:nvm 专属方案使用 nvm 管理多版本 Node.js⭐⭐⭐⭐低方案五:Windows 专属Windows 系统⭐⭐⭐⭐⭐低方案六:Homebrew 安装macOS 用户,npm 有问题⭐⭐⭐低根本原因。

博客 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万+

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

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...

旺崽的博客 3054

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Codeforces Round #588 (Div. 2)

Codeforces Round #588 (Div. 2) AB略 C. Anadi and Domino 题意: 有如图所示的 21 个多米诺骨牌,给定一个无向图(无自环,无重边),一条边上可以放置一个多米诺骨牌。要求是如果两条边连接同一个顶点,那就必须使这两条边上的多米诺骨牌指向这个顶点的值相等,可以有不放的情况,问给定的图中最多可以放多少个多米诺骨牌。(n<=7) 思路: 假设n&...

mzip的博客 337

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Codeforces Round #326 (Div. 2)B.Duff in love

Codeforces Round #326 (Div. 2)B.Duff in love http://codeforces.com/problemset/problem/588/B 简单数论 题目大意:给一个n,找出它的所有因数中的最大的lovely数 (lovely数指的是不能整除a^2,a>2) 我一开始比较愚蠢的想把所有的因数放一个数组里面,然后再从大到小一一判断。 然后光是数组就已...

想要一只银渐层 242

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

旺崽的博客 2574

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 ...

旺崽的博客 2513

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

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...

亦申的博客 1079

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...

旺崽的博客 3112

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 850

9.21 Codeforces Round #587 (Div. 3)

#587:http://codeforces.com/contest/1216 #582:http://codeforces.com/contest/1213

放荡者的茶会 421

Codeforces Round #247 (Div. 2) ABC

Codeforces Round #247 (Div. 2)

水果君の日常 2091
上一篇: OJ的搭建
下一篇: Codeforces Round #325 (Div. 2) (586A,586B,585A,585B)
yphacker
博客等级 码龄12年 199粉丝 540原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址