文章

48

粉丝

317

获赞

57

访问

28.8k

头像
复数集合 题解:大根堆+运算符重载
P1381 北京邮电大学机试题
发布于2025年3月12日 13:42
阅读数 18

#include<iostream>
#include<queue>
#include<string>
using namespace std;
struct El 
{
    int a;
    int b;

};

bool operator <(El e1, El e2)
{
    if ((e1.a * e1.a + e1.b * e1.b) < (e2.a * e2.a + e2.b * e2.b)) return true;
    return false;


}


int main() 
{
    int n;
    while (cin >> n)
    {
        priority_queue<El> pq;
        for (size_t i = 0; i < n; i++)
        {
            string str;
            cin >> str;
            if (str == "Pop")
            {
           &...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发