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

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

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;
}



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

相关推荐

MDK开发篇:基于立创逻辑派FPGA-G1与Cortex-M1软核的按键控制LED实战

本文详细介绍了基于立创逻辑派FPGA-G1开发板与高云Cortex-M1软核的完整开发流程。通过Gowin云源软件配置软核系统与GPIO外设,并在Keil MDK环境中编写按键控制LED的C程序,最终实现程序固化与上电自启动。教程涵盖硬件配置、软件开发、在线调试与固化部署全步骤,帮助STM32开发者快速上手FPGA软核开发。

weixin_42103128的博客 147

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的世界 358

AI智能体协作:构建更精准的公司破产预测模型

公司破产预测对于金融机构、投资者和监管部门等具有至关重要的意义。准确的破产预测可以帮助金融机构提前做好风险防范,避免贷款损失;投资者可以根据预测结果调整投资组合,降低投资风险;监管部门可以及时发现潜在的金融风险,采取相应的监管措施。然而,传统的公司破产预测模型往往存在精度不高的问题,无法满足实际需求。本研究的目的是利用AI智能体协作的方式,构建一个更精准的公司破产预测模型。通过将多个AI智能体的优势进行整合,充分挖掘公司财务数据、市场数据等多源数据中的信息,提高预测的准确性和可靠性。

2501_92132293的博客 1081

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

告别瞎猜!用通达信L2资金流向函数,手把手教你识别主力动向(附实战公式)

本文详细解析通达信L2资金流向函数,手把手教你构建主力动向监控系统。通过分档数据解析、委买委卖攻防解读及实战公式应用,帮助投资者精准识别主力建仓与虚假拉升信号,提升股票交易决策效率。

weixin_26908317的博客 2074

【Qt】Qt6系列教程汇总_qt6教程

简介:QT相关电子书、建议和相关参考网址。

2401_87556657的博客 1183

Codeforces 588B Duff in Love 【数学】

题目链接:Codeforces 588B Duff in Love B. Duff in Love time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Duff is in love with lovely numbers! A

世界很大 809

[Python图像处理] 一.图像处理基础知识及OpenCV入门函数

该系列文章是讲解Python OpenCV图像处理知识,前期主要讲解图像入门、OpenCV基础用法,中期讲解图像处理的各种算法,包括图像锐化算子、图像增强技术、图像分割等,后期结合深度学习研究图像识别、图像分类应用。希望文章对您有所帮助,如果有不足之处,还请海涵~ 同时推荐作者的C++图像系列知识: [数字图像处理] 一.MFC详解显示BMP格式图片 [数字图像处理] 二.MFC单文档分割窗...

杨秀璋的专栏 7万+

Duff and Meat - CF 588A

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

weixin_30735391的博客 103

华为OD面试八股真题 - 操作系统 - 1

华为OD技术面,操作系统相关八股真题提供详细解答,这篇博客主要涉及于进程和线程相关知识点

qq_45776114的博客 1632

【Bug已解决】Failed to fetch version ECONNREFUSED 解决方案

方案适用场景推荐指数难度方案一:NODE_EXTRA_CA_CERTS代理/企业网关证书⭐⭐⭐⭐⭐低方案二:浏览器导出证书不知证书在哪⭐⭐⭐⭐中方案三:使用系统证书macOS 用户⭐⭐⭐⭐中方案四:关闭代理直连快速验证⭐⭐⭐低方案五:更新 Node.js证书列表过时⭐⭐⭐低方案六:同步系统时间时间偏差导致⭐⭐⭐低根本原因。

博客 9972

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

双Orin PCIe RC&EP模式互通

orin pcie 互通

乐于分享 3877

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

老版QQ原生表情gif动态

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

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Codeforces Round #588 (Div. 2)

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

mzip的博客 334

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

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

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

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

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

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

亦申的博客 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 #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

9.21 Codeforces Round #587 (Div. 3)

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

放荡者的茶会 418

Codeforces Round #247 (Div. 2) ABC

Codeforces Round #247 (Div. 2)

水果君の日常 2090

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
上一篇: 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、付费专栏及课程。

余额充值