sgu 150 分类: sgu 2015-04...

本文介绍了一种解决特定数学问题的算法实现,通过C++编程语言,利用向量和比较函数来找出满足条件的坐标点,该算法适用于寻找两点间线性路径上的第n个点。

算是数学题吧。


#include<map>
#include<queue>
#include<stack>
#include<ctime>
#include<cmath>
#include<string>
#include<cstdio>
#include<utility>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>

const int INF = 1<<30;

struct Vector{int x,y;Vector(int x = 0,int y = 0):x(x),y(y){}};

bool flag = false;

int cmp(int a,int b)
{
    if(b > a)
        return 1;
    else if(b < a)
        return -1;
    else  
        return 0; 
}
int main()
{
    Vector move;
    int x1,x2,y1,y2,n; 
    int ansx,ansy;
    int sx,sy,cnt = 0;

#ifndef ONLINE_JUDGE
    freopen("sgu150.in","r",stdin);
    freopen("sgu150.out","w",stdout);
#endif

    std::cin >> x1 >> y1 >> x2 >> y2 >> n;

    sx = cmp(x1,x2), sy = cmp(y1,y2);
    move = Vector(abs(x2-x1),abs(y2-y1));

    if(move.x && move.y) 
     for(int x = 1, yl = 0, yn, yt; x <= abs(x2-x1) && !flag ; x ++)
     {
        yn = (long long)x*move.y/move.x;
        yt = (long long)x*move.y%move.x;

        cnt += yn - yl + (yt?1:0);

        if(cnt >= n) 
        {
            flag = true;
            ansx = x - 1, ansy = yn - (cnt-n) - (yt?0:1);
            if(sx < 0) ansx = -(ansx + 1);
            if(sy < 0) ansy = -(ansy + 1);
            ansx += x1, ansy += y1;
        }

        yl = yn;
     }

     if(flag) std::cout << ansx << ' ' << ansy << std::endl;
     else     std::cout << "no solution" << std::endl;


#ifndef ONLINE_JUDGE
    fclose(stdin);
    fclose(stdout);
#endif
    return 0;           
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/dashgua/p/4723034.html

内容概要:本文聚焦于针对采用卡尔曼滤波(KF)进行状态估计的电力系统,研究虚假数据注入攻击(FDIA)的机理与仿真方法,并通过Matlab代码实现完整的攻击模型。研究系统地分析了攻击者如何构造符合系统统计特性的隐蔽虚假数据,以规避传统不良数据检测机制,在不被察觉的情况下扭曲系统状态估计结果,进而威胁电力系统的运行监控与决策安全性。文中详细阐述了KF状态估计算法原理、攻击向量的数学建模与构造方法,并提供了可运行的Matlab代码,便于读者复现攻击过程,深入理解其内在机理与潜在风险。; 适合人群:具备电力系统分析、现代控制理论(特别是状态估计)基础知识,以及熟练Matlab编程能力的科研人员、高校研究生和从事电力系统网络安全防护工作的工程技术人员。; 使用场景及目标:①深入剖析基于卡尔曼滤波的电力系统状态估计的安全脆弱性;②研究虚假数据注入攻击的可行性、隐蔽性及危害程度;③为开发和验证新型攻击检测算法与防御策略提供精确的仿真攻击案例和测试平台。; 阅读建议:建议读者在充分掌握电力系统状态估计和卡尔曼滤波理论的基础上,仔细研读并运行所提供的Matlab代码,通过调整系统参数、噪声水平和攻击强度等变量,观察其对状态估计偏差的影响,从而深刻理解攻击的本质特征与防范的关键点。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值