本文介绍了如何分割数字x,其中x1是完美的正方形和i,e 50 = 49 + 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何分割数字x,其中x1是完美的正方形,我,e 50 = 49 + 1

直到结束



我尝试过:



how to split number x where x1 is perfect square and i,e 50=49+1
till end

What I have tried:

#include <stdio.h>

int main()
{
    int a, n;
    printf("Enter a number: ");
    scanf("%d", &n);
    for(a = 0; a <= n; a++)
    {
        if (n == a * a)
        {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}</stdio.h>

推荐答案

X = Y*Y + Z*Z, where X is a perfect square.



我可能首先要确定所有的完美的正方形小于X,然后开始寻找组合,取最大值,加上最低值,看看是否匹配。

如果确实如此,你就完成了。

如果它低于X,请尝试下一个最低值并重复。

如果它大于X,请尝试下一个最高值并重复。

如果Y == Z它不存在。



但这是你的作业,所以我不会给你任何代码!


I'd probably start by identifying all the perfect squares less than X, and then start looking for "combinations", by taking the largest, adding the lowest and seeing if it matches.
If it does, you're done.
If it's lower than X, try the next lowest and repeat.
If it's greater than X, try the next highest and repeat.
If Y==Z it doesn't exist.

But this is your homework, so I won't give you any code!


这篇关于如何分割数字x,其中x1是完美的正方形和i,e 50 = 49 + 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 12:34