CSDN-Ada助手 2023-12-31 18:18 采纳率: 1.6%
浏览 4

Codeforces Round 891 (Div. 3) F|“朝闻道”知识分享大赛_(语言-c++)

该问题来自社区帖: https://bbs.csdn.net/topics/617826672.为符合问答规范, 该问题经过ChatGPT优化
<html><body>

Codeforces Round 891 (Div. 3) F|“朝闻道”知识分享大赛

这是我参加朝闻道知识分享大赛的第29篇文章.

Problem - F - Codeforces

x+y=a, xy=b 可以转换为二元一次方程 x^2-ax+b=0,解方程就行

第一发交,cf居然提示我哪里可能错了,真的哭死,要是自己找错肯定又要找半天T.T,最近总是乘法爆long long爆 int

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define _cf() int _;cin>>&_;while(_--)
const int N = 2e6;
const int inf = 2147483647;
void Solve()
{
    int n;
    cin>>&n;
    ll x;
    map vis;
    for(int i=1;i<=n;i++) cin>>&x,vis[x]++;
    int m;cin>>&m;
    long double a,b;
    while(m--)
    {
        ll res=0;
        cin>>&a>>&b;
        long double x1=(a+sqrt(a*a-4*b))/2;
        long double x2=(a-sqrt(a*a-4*b))/2;
        if(x1==(int)x1)
        {
            int y1=a-x1;
            if(x1==y1) res+=vis[x1]*(vis[x1]-1)/2;
            else res+=vis[x1]*vis[y1];
        }
        if(x1!=x2&&x2==(int)x2)
        {
            int y2=a-x2;
            if(y2!=x1){
                if(x2==y2) res+=vis[x2]*(vis[x2]-1)/2;
                else res+=vis[x2]*vis[y2];
            }
        }
        cout<
</body></html>
  • 写回答

2条回答 默认 最新

  • IT工程师_二师兄 2023-12-31 18:34
    关注

    你把报错截图单独发给我

    评论

报告相同问题?

问题事件

  • 创建了问题 12月31日