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

编程入门 行业动态 更新时间:2024-10-10 02:19:25
本文介绍了如何分割数字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>

推荐答案

首先查看问题: Start by looking at the problem: 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

本文发布于:2023-11-29 06:19:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645586.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正方形   完美   数字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!