强训第37天

选择

B

D

D

网络号最高才247开头

主机号全为0是网络号

D

28位网络号 则第四个字节是1111 0000(240) 按位与91得80(0101 0000)

最大就是后面四个主机号全为1即80+15=95而且是广播IP

或者全部拿来比一下网络号

B

首先发数据肯定从低到高发。网络中要转成大端字节序。

在x86平台上为小端存储在内存上由低到高位12 34 56 78,转为大端变成 78 56 34 12

所以顺序是78 56 34 12

A

主机号占九位 2^9=512 减网络号 广播 和网关设备 =509

D

子网掩码要是连续的

D

DNS用的UDP

A

D

需要六个子网 所以需要至少3位充当网络号 所以剩了5个比特位充当主机号(2^5>26)符合

所以第四个字节的前三个字节是1 1110 0000为224

编程

数据库连接池

数据库连接池__牛客网

cpp 复制代码
#include <iostream>
#include <string.h>
#include <vector>
#include <string>
using namespace std;

int main() 
{
    int n;
    while(cin>>n)
    {
        string num,op;
        int res=0;
        int have=0;
        for(int i=0;i<n;i++)
        {
            cin>>num>>op;
            if(op=="connect")
            {
                if(have==0) res++;
                else have--;
            }
            else
            {
                have++;
            }
        }
        cout<<res<<endl;
    }
    return 0;
}

mkdir

mkdir__牛客网

cpp 复制代码
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() 
{
    int n;
    while(cin>>n)
    {
        vector<string>strs(n);
        vector<bool>exist(n,true);
        for(int i=0;i<n;i++) 
        {
            // getline(cin,strs[i]);
            // getline会把空格也识别上来 慎用
            cin>>strs[i];
        }
        sort(strs.begin(),strs.end());
        for(int i=0;i<n-1;i++)
        {
            if(strs[i]==strs[i+1])
            {
                exist[i]=false;
            }
            else if(strs[i]==strs[i+1].substr(0,strs[i].size()) && strs[i+1][strs[i].size()] == '/')
            {
                exist[i]=false;
            }
        }
        string tmp="mkdir -p ";
        for(int i=0;i<strs.size();i++)
        {
            if(exist[i])
            {
                cout<<tmp<<strs[i]<<endl;
            }
        }
        cout<<endl;
    }
    return 0;
}
相关推荐
皓月斯语1 小时前
B3842 [GESP202306 三级] 春游 题解
数据结构·c++·算法·题解
萌动的小火苗2 小时前
嵌入式开发中的栈与队列:任务调度为什么依赖数据结构
数据结构·c++·单片机·嵌入式硬件
星恒随风3 小时前
C++ STL 栈详解:stack 的使用、经典题目与简单模拟实现
开发语言·数据结构·c++·笔记·学习
txzrxz3 小时前
单调队列讲解
数据结构·c++·算法·单调队列
WWTYYDS_6664 小时前
JsonCpp超详细使用教程
c++
Joey_friends4 小时前
指纹authenticate流程图
android·java·c++
小小晓.4 小时前
C++小白记:C风格字符串和数组用法
c语言·开发语言·c++
cpp_25014 小时前
P1540 [NOIP 2010 提高组] 机器翻译
数据结构·c++·算法·队列·noip·洛谷题解
咕白m6255 小时前
通过 C++ 写入数据到 Excel 文档
c++·后端
qz5zwangzihan16 小时前
题解:Atcoder Beginner Contest abc467 F - Email Scheduling Optimization
c++·贪心·atcoder·平衡树·abc467·abc467_f·fhq-treap