3.09 复试学习

oj125 回文+镜面

cpp 复制代码
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
//镜面表
char mirror[256]={0};
void initMirror(){
    mirror['A']='A';mirror['M']='Y';mirror['Y']='Y';
    mirror['E']='3';mirror['O']='O';mirror['Z']='5';
    mirror['H']='H';mirror['S']='2';mirror['1']='1';
    mirror['I']='I';mirror['T']='T';mirror['2']='S';
    mirror['J']='L';mirror['U']='U';mirror['3']='E';
    mirror['L']='J';mirror['V']='V';mirror['5']='Z';
    mirror['W']='W';mirror['X']='X';mirror['8']='8';
}
//判断是否回文
bool isHuiwen(const string& s){
    int n=s.size();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-1-i]){
           return false;
           }
    }
    return true;
}
//判断是否镜面
bool isMirror(const string& s){
    int n=s.size();
    for(int i=0;i<n;i++){
            char c=s[i];
            char exc=s[n-1-i];
        if(mirror[c]==0){
            return false;
        }
        if(mirror[c]!=exc){
            return false;
        }
    }
    return true;
}

int main()
{
    initMirror();//直接调入就行
    string s;
    while(cin>>s){
        bool huiwen=isHuiwen(s);
        bool mirr=isMirror(s);

        if(!huiwen&&!mirr){
            cout<<s<<" -- is not a palindrome."<<endl;
        }else if(huiwen&&!mirr){
            cout<<s<<" -- is a regular palindrome."<<endl;
        }else if(!huiwen&&mirr){
            cout<<s<<" -- is a mirrored string."<<endl;
        }else if(huiwen&&mirr){
            cout<<s<<" -- is a mirrored palindrome."<<endl;
        }

        cout<<endl;

    }


    return 0;
}

利用数组,结合ASCII,构建对应数组。在main里直接调用init函数就好。回文的判断和镜面的判断,都可以用一维数组,对应位置去判断就好了。不修改的可以用const string& s,一般情况下,用string s就足够了。

oj126 数列2

可以不连续-枚举子集

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

int main() {
    int n;
    while (cin >> n) {
        int a[15];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        int count = 0;
        // 枚举所有非空子集 (mask 从 1 到 2^n - 1)
        for (int mask = 1; mask < (1 << n); mask++) {
            int sum = 0;
            for (int i = 0; i < n; i++) {
                if (mask & (1 << i)) { // 检查第i位是否选中
                    sum += a[i];
                }
            }
            if (sum % 11 == 0) {
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}

oj111 统计选票

cpp 复制代码
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>

using namespace std;

struct candidate {
    string name;
    int result;
};

// 自定义排序规则
bool compareCandidates(const candidate& a, const candidate& b) {
    if (a.result != b.result) {
        return a.result > b.result; // 票数多的在前
    }
    return a.name > b.name; // 票数相同
}

int main() {
    candidate H[3];
    H[0] = {"zhang", 0};
    H[1] = {"li", 0};
    H[2] = {"wang", 0};

    int wrong_count = 0;

    for (int i = 0; i < 10; i++) {
        string s;
        cin >> s;

        // 转小写
        for (size_t j = 0; j < s.length(); j++) {
            s[j] = tolower((unsigned char)s[j]);
        }

        if (s == "zhang") {
            H[0].result++;
        } else if (s == "li") {
            H[1].result++;
        } else if (s == "wang") {
            H[2].result++;
        } else {
            wrong_count++;
        }
    }

    // 排序!
    sort(H, H + 3, compareCandidates);

    // 输出排序后的结果
    for (int i = 0; i < 3; i++) {
        cout << H[i].name << ":" << H[i].result << endl;
    }

    // 输出废票
    cout << "Wrong election:" << wrong_count << endl;

    return 0;
}

数组 记得初始化

观察输入情况,记得全转为大写/小写,要利用数组一位一位转;注意数组要如何用sort

oj63 哥德巴赫

素数判断+按题目要求;找出关系等式即可。

cpp 复制代码
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

//素数判断
bool isSushu(int n){
    if(n<2) return false;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

int main()
{
    int n;
    while(n--){
            int a;
        cin>>a;
        //找
        for(int p=2;p<a/2;p++){
            int q=a-p;
            if(isSushu(p)&&isSushu(q)){
                cout<<p<<" "<<q<<endl;
                break;//找到立马停 换
            }
        }
    }
    return 0;
}

oj78 方块转换

找好对应关系

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

// 比较两个矩阵是否相等
bool equal(const vector<string>& a, const vector<string>& b) {
    return a == b;
}

// 顺时针旋转90度
vector<string> rotate90(const vector<string>& grid) {
    int n = grid.size();
    vector<string> res(n, string(n, ' '));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            res[i][j] = grid[n - 1 - j][i];
        }
    }
    return res;
}

// 水平翻转(左右镜像)
vector<string> flipHorizontal(const vector<string>& grid) {
    int n = grid.size();
    vector<string> res = grid;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n / 2; j++) {
            swap(res[i][j], res[i][n - 1 - j]);
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    
    vector<string> original(n);
    for (int i = 0; i < n; i++) {
        cin >> original[i];
    }
    
    vector<string> target(n);
    for (int i = 0; i < n; i++) {
        cin >> target[i];
    }
    
    // 尝试所有变换(按优先级顺序)
    vector<string> current;
    
    // #1: 90度
    current = rotate90(original);
    if (equal(current, target)) {
        cout << 1 << endl;
        return 0;
    }
    
    // #2: 180度
    current = rotate90(current); // 90+90=180
    if (equal(current, target)) {
        cout << 2 << endl;
        return 0;
    }
    
    // #3: 270度
    current = rotate90(current); // 180+90=270
    if (equal(current, target)) {
        cout << 3 << endl;
        return 0;
    }
    
    // #4: 水平翻转
    vector<string> flipped = flipHorizontal(original);
    if (equal(flipped, target)) {
        cout << 4 << endl;
        return 0;
    }
    
    // #5: 翻转 + 旋转(90, 180, 270)
    current = rotate90(flipped);
    if (equal(current, target)) {
        cout << 5 << endl;
        return 0;
    }
    
    current = rotate90(current);
    if (equal(current, target)) {
        cout << 5 << endl;
        return 0;
    }
    
    current = rotate90(current);
    if (equal(current, target)) {
        cout << 5 << endl;
        return 0;
    }
    
    // #6: 不变
    if (equal(original, target)) {
        cout << 6 << endl;
        return 0;
    }
    
    // #7: 无效
    cout << 7 << endl;
    return 0;
}

oj71 发牌

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

// 比较两个矩阵是否相等
bool equal(const vector<string>& a, const vector<string>& b) {
    return a == b;
}

// 顺时针旋转90度
vector<string> rotate90(const vector<string>& grid) {
    int n = grid.size();
    vector<string> res(n, string(n, ' '));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            res[i][j] = grid[n - 1 - j][i];
        }
    }
    return res;
}

// 水平翻转(左右镜像)
vector<string> flipHorizontal(const vector<string>& grid) {
    int n = grid.size();
    vector<string> res = grid;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n / 2; j++) {
            swap(res[i][j], res[i][n - 1 - j]);
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    
    vector<string> original(n);
    for (int i = 0; i < n; i++) {
        cin >> original[i];
    }
    
    vector<string> target(n);
    for (int i = 0; i < n; i++) {
        cin >> target[i];
    }
    
    // 尝试所有变换(按优先级顺序)
    vector<string> current;
    
    // #1: 90度
    current = rotate90(original);
    if (equal(current, target)) {
        cout << 1 << endl;
        return 0;
    }
    
    // #2: 180度
    current = rotate90(current); // 90+90=180
    if (equal(current, target)) {
        cout << 2 << endl;
        return 0;
    }
    
    // #3: 270度
    current = rotate90(current); // 180+90=270
    if (equal(current, target)) {
        cout << 3 << endl;
        return 0;
    }
    
    // #4: 水平翻转
    vector<string> flipped = flipHorizontal(original);
    if (equal(flipped, target)) {
        cout << 4 << endl;
        return 0;
    }
    
    // #5: 翻转 + 旋转(90, 180, 270)
    current = rotate90(flipped);
    if (equal(current, target)) {
        cout << 5 << endl;
        return 0;
    }
    
    current = rotate90(current);
    if (equal(current, target)) {
        cout << 5 << endl;
        return 0;
    }
    
    current = rotate90(current);
    if (equal(current, target)) {
        cout << 5 << endl;
        return 0;
    }
    
    // #6: 不变
    if (equal(original, target)) {
        cout << 6 << endl;
        return 0;
    }
    
    // #7: 无效
    cout << 7 << endl;
    return 0;
}

翻译:

With the increasing popularity of smart wearable devices, such as earbuds and smart watches, presents new challenges for seamless and secure user authentication due to their limited user interfaces. Conventional biometric methods, including voice, fingerprints, and facial recognition often face issues such as usability limitations, interference from noise, or vulnerability to spoofing attacks. This paper introduces a novel authentication system called BaroAuth, which utilizes the stable and unique Speech-aware Pressure Sequences (SPSs) patterns captured by a miniaturized MEMS barometer embedded in earbuds. The design of BaroAuth hinges on two important observations. First, the production of speech relies on the coordinated movements of articulatory organs, including the tongue, jaw, and soft palate. These organs, through the activity of the temporomandibular joint (TMJ), alter the shape of the ear canal, thereby causing subtle pressure changes that encode the speaker's unique physiological characteristics and articulatory dynamics. Second, SPSs show significant intra-individual consistency and considerable inter-individual variability, which barometers can effectively measure. Meanwhile, we develop the BaroAuth prototype and carry out comprehensive experiments based on it. The experimental findings reveal that BaroAuth demonstrates a mean false-acceptance rate (FAR) of 0.41% and a false-rejection rate (FRR) of 1.23%, respectively, even under complex attack scenarios.

随着智能可穿戴设备(如耳机和智能手表)的日益普及,由于其用户交互界面受限,如何实现无缝且安全的用户认证成为了新的挑战。传统的生物识别方法(包括语音、指纹和面部识别)往往面临可用性受限、噪声干扰或易受欺骗攻击等问题。本文提出了一种名为 BaroAuth 的新型认证系统,该系统利用嵌入在耳机中的微型 MEMS 气压计所捕获的稳定且独特的"语音感知压力序列"(SPSs)模式。BaroAuth 的设计基于两个重要观察:首先,语音的产生依赖于发音器官(包括舌头、下颚和软腭)的协调运动。这些器官通过颞下颌关节(TMJ)的活动改变耳道的形状,从而引起细微的压力变化,这些变化编码了说话者独特的生理特征和发音动态。其次,SPSs 表现出显著的个体内一致性和相当大的个体间差异性,而气压计能够有效地测量这些特征。与此同时,我们开发了 BaroAuth 原型并进行了全面的实验。实验结果表明,即使在复杂的攻击场景下,BaroAuth 的平均误识率(FAR)仅为 0.41%,拒真率(FRR)为 1.23%。

基于深度学习的智能软件的可靠性已成为软件测试领域的一个关键挑战。本文首先概述了智能软件测试的核心概念,并从三个维度------数据、模型(即算法)和平台(即框架)------系统分析了削弱可靠性的主要不确定性来源。随后,文章识别出可靠性测试中的主要挑战,重点聚焦于测试用例生成、测试方法论以及评估标准。接着,总结了相关技术的最新进展。最后,提出了未来有前景的研究方向,旨在为推动可靠深度学习软件的发展提供新的见解。

相关推荐
Xudde.7 小时前
班级作业笔记报告0x04
笔记·学习·安全·web安全·php
CoderCodingNo7 小时前
【NOIP】2011真题解析 luogu-P1003 铺地毯 | GESP三、四级以上可练习
算法
晓晓hh8 小时前
JavaSE学习——迭代器
java·开发语言·学习
iFlyCai8 小时前
C语言中的指针
c语言·数据结构·算法
Laurence8 小时前
C++ 引入第三方库(一):直接引入源文件
开发语言·c++·第三方库·添加·添加库·添加包·源文件
查古穆8 小时前
栈-有效的括号
java·数据结构·算法
再一次等风来8 小时前
近场声全息(NAH)仿真实现:从阵列实值信号到波数域重建
算法·matlab·信号处理·近场声全息·nah
汀、人工智能8 小时前
16 - 高级特性
数据结构·算法·数据库架构·图论·16 - 高级特性
大熊背8 小时前
利用ISP离线模式进行分块LSC校正的方法
人工智能·算法·机器学习
XWalnut9 小时前
LeetCode刷题 day4
算法·leetcode·职场和发展