UVa11565 - Simple Equations

简介: UVa11565 - Simple Equations
#include <cstdio>usingnamespacestd;
inta, b, c;
boolinput();
voidsolve();
intmain()
{
#ifndef ONLINE_JUDGEfreopen("d:\\OJ\\uva_in.txt", "r", stdin);
#endifintn;
scanf("%d", &n);
while (n--) {
input();
solve();
    }
return0;
}
boolinput()
{
scanf("%d%d%d", &a, &b, &c);
returntrue;
}
voidsolve()
{
boolfound=false;
intx, y, z;
for (x=-22; x<=22&&!found; x++) {
if (x*x<=c) {
for (y=-100; y<=100&&!found; y++) {
if (y!=x&&x*x+y*y<=c) {
for (z=-100; z<=100&&!found; z++)  {
if (z!=x&&z!=y&&x+y+z==a&&x*y*z==b&&x*x+y*y+z*z==c) {
printf("%d %d %d\n", x, y, z);
found=true;
                            }
                    }
                }
            }
        }
    }
if (!found) {
printf("No solution.\n");
    }
}
目录
相关文章
UVa389 - Basically Speaking
UVa389 - Basically Speaking
40 0
UVa11714 - Blind Sorting
UVa11714 - Blind Sorting
55 0
|
Java
HDU - 2018 Multi-University Training Contest 2 - 1004: Game
HDU - 2018 Multi-University Training Contest 2 - 1004: Game
107 0
|
Python
lecture 1 练习
Assume that two variables, varA and varB, are assigned values, either numbers or strings.
1100 0
|
机器学习/深度学习 自然语言处理
uva live 3516 - Exploring Pyramids
点击打开链接 题意:给出一棵多叉树,每个结点的任意两个子节点都有左右之分。从根节点开始,每次尽量往左走,走不通就回溯,把遇到的字母顺序记录下来,可以得到一个序列。
775 0

热门文章

最新文章