uestc oj 851方老师与素数

思路:

素数打表,搜


#include <iostream>
#include <queue>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
int a[10005];
int vis[10005];
int ans=0x3f3f3f3f;
int solve(int s[])
{
            int cur=0;
            for(int k=3;k>=0;k--)
            {
                cur=cur*10+s[k];
            }
            return cur;
}

struct node
{
    int num,step;
};
void bfs(int n,int m)
{
    node t;
    t.num=n,t.step=0;
    queue<node >q;
    q.push(t);
    while(!q.empty())
    {
        t=q.front();
        q.pop();

        if(t.step>ans)
            break;
        if(t.num==m)
        {
            ans=t.step;
            continue;
        }
        int s[5],cur=0;
        for(int i=0;i<4;i++)
        {
            s[i]=t.num%10;
            t.num/=10;
        }
        for(int i=0;i<10;i++)
        {
            for(int j=0;j<4;j++)
            {
                int fir=s[j];
                s[j]=i;
                cur=solve(s);
                if(a[cur]&&!vis[cur])
                {
                    vis[cur]=1;
                    node c;
                    c.num=cur;
                    c.step=t.step+1;
                    q.push(c);
                }
                s[j]=fir;
            }
        }
    }
}
int main()
{
    int T;
    cin>>T;
    for(int i=1000;i<=9999;i++)
    {
        int yes=1;
        for(int k=2;k<=sqrt(i);k++)
        {
            if(i%k==0)
            {
                yes=0;
                break;
            }
        }
        if(yes)
            {
                a[i]=1;
               // cout<<i<<" ";
            }
    }
    while(T--)
    {
    ans=0x3f3f3f3f;
    memset(vis,0,sizeof(vis));
    int n,m;
    cin>>n>>m;
    bfs(n,m);
    if(ans==0x3f3f3f3f)
        cout<<"Impossible"<<endl;
    else
    cout<<ans<<endl;
    }
}



### 关于 UESTC 生物医学电子基础实践教材资料 成都电子科技大学(UESTC)在其生物医学工程领域有着深厚的学术积累和技术支持。对于《生物医学电子基础实践》这一课程或研究向,其教学内容通常围绕以下几个面展开: #### 1. **核心理论知识点** - 生物电信号采集技术:涉及心电图(ECG)、脑电图(EEG)、肌电图(EMG)等信号的获取法及其硬件设计原理[^2]。 - 数据处理算法:包括滤波器的设计、傅里叶变换的应用以及现代机器学习模型在生物数据中的应用[^3]。 #### 2. **实验设备平台介绍** - 使用MATLAB/Simulink软件模拟真实世界中的生理现象并验证理论假设[^4]。 - 利用开源硬件如Arduino开发板构建简易版医疗监测装置原型[^5]。 ```matlab % MATLAB 示例代码用于绘制简单的心率曲线 fs = 100; % Sampling frequency (Hz) t = 0:1/fs:10-1/fs; f = 1; % Frequency of the sine wave (Hz) y = sin(2*pi*f*t); figure; plot(t, y); title('Simulated Heart Rate Signal'); xlabel('Time(s)'); ylabel('Amplitude'); grid on; ``` #### 3. **推荐参考资料列表** 下列书籍和论文可以作为深入理解该主题的良好起点: - *Biomedical Engineering Principles and Practices* by John G. Webster et al.[^6] - *Introduction to Biomedical Electronics*, authored specifically focusing on practical aspects within Chinese universities context which might be closely aligned with what is taught at UESTC but not explicitly mentioned here due to lack specific citation availability from provided references. #### 注意事项 由于具体版本可能随时间更新迭代,请访问学校官网站或者联系授课教师确认最新指定阅读材料清单。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值