Jayfeather松鸦羽_sch 2025-04-18 19:14 采纳率: 0%
浏览 30

在洛谷提交“SP7733”为什么UKE

#问题
是SP7733 HPYNOS - Happy Numbers I UKE了
#描述
先附代码,本地测试通过

#include<bits/stdc++.h>
using namespace std;
int t,n,ct;
bool isHappy()
{
    unordered_set<int>seen;
    while(n!=1&&seen.find(n)==seen.end())
    {
        seen.insert(n);
        int sum=0;
        for(int i=n;i>0;i/=10)
        {
            int digit=i%10;
            sum+=digit*digit;
        }
        n=sum;
        ct++;
    }
    return n==1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    if(isHappy())
    {
        cout<<ct;
    }
    else
    {
        cout<<"-1";
    }
    return 0;
}

这是显示的

RequestError: error sending request for url (https://www.spoj.com/login): error trying to connect: tcp connect error: Connection timed out (os error 110)
怎样才能在洛谷AC这个?

  • 写回答

4条回答 默认 最新

  • 阿里嘎多学长 2025-04-18 19:14
    关注

    阿里嘎多学长整理AIGC生成,因移动端显示问题导致当前答案未能完全显示,请使用PC端查看更加详细的解答过程

    问题解答

    你在洛谷提交的代码使用了SP7733 HPYNOS - Happy Numbers I,然而在UKE平台上却报错了。根据你提供的代码,问题可能出在代码中的某个地方。

    首先,代码中使用了#include <bits/stdc++.h>,这可能会导致编译器报错,因为UKE平台可能不支持这个头文件。

    其次,代码中使用了using namespace std;,这可能会导致命名空间冲突。

    建议你尝试以下解决方案:

    1. #include <bits/stdc++.h>更换为#include <iostream>#include <cstdio>等标准头文件。
    2. 删除using namespace std;语句,使用std::前缀来访问标准库中的函数和变量。

    如果问题仍然存在,请提供更多的代码和错误信息,我将尽力帮助你解决问题。

    评论

报告相同问题?

问题事件

  • 创建了问题 4月18日