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");
    }
}
目录
相关文章
|
5月前
Strange fuction(HDU--2899)
Strange fuction(HDU--2899)
|
11月前
|
图形学
hdu1086 You can Solve a Geometry Problem too(判断线段相交)
hdu1086 You can Solve a Geometry Problem too(判断线段相交)
56 0
UVa11714 - Blind Sorting
UVa11714 - Blind Sorting
50 0
UVa389 - Basically Speaking
UVa389 - Basically Speaking
35 0
AtCoder Beginner Contest 176 D - Wizard in Maze(01BFS)
AtCoder Beginner Contest 176 D - Wizard in Maze(01BFS)
111 0
|
开发者
牛客第六场-Combination of Physics and Maths
题意:选出一个子矩阵,使得所求的压强最大,压强是指这个子矩阵中每个元素之和 / 这个子矩阵最下面一行的元素之和
55 0
牛客第六场-Combination of Physics and Maths
|
机器学习/深度学习 自然语言处理
【HDU 5572 An Easy Physics Problem】计算几何基础
2015上海区域赛现场赛第5题。 题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5572 题意:在平面上,已知圆(O, R),点B、A(均在圆外),向量V。
1030 0