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");
    }
}
目录
相关文章
|
3天前
Strange fuction(HDU--2899)
Strange fuction(HDU--2899)
|
6月前
|
图形学
hdu1086 You can Solve a Geometry Problem too(判断线段相交)
hdu1086 You can Solve a Geometry Problem too(判断线段相交)
27 0
|
9月前
UVa11714 - Blind Sorting
UVa11714 - Blind Sorting
36 0
AtCoder Beginner Contest 176 D - Wizard in Maze(01BFS)
AtCoder Beginner Contest 176 D - Wizard in Maze(01BFS)
89 0
|
Perl
AtCoder Beginner Contest 217 F - Make Pair (区间dp)
AtCoder Beginner Contest 217 F - Make Pair (区间dp)
94 0
|
Java
HDU - 2018 Multi-University Training Contest 2 - 1004: Game
HDU - 2018 Multi-University Training Contest 2 - 1004: Game
77 0
|
Java
HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube
HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube
106 0
HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube
|
机器学习/深度学习 自然语言处理