题目链接:
思路
拿到题目,注意到式子:。看到平方与2倍,迅速想到完全平方公式:
这里令,显然有
,变形得
。由初中数学知识可知
,即
,还原后得
这说明,,则若存在满足题意的
,必有
结束力!
AC code
既然没人用Java,那我就来个Java题解吧
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while( (t --) != 0 ){ // 模仿C++ while( t -- )的小技巧
long a = in.nextLong(), b = in.nextLong(), c = in.nextLong();
// 十年OI一场空,不开long long 见祖宗
if( b * c % a == 0 ) System.out.println(b * c / a);
else System.out.println(-1);
}
}
}
PS一下
为什么我觉得做这道题有种做CTF解题模式的题目的感觉

京公网安备 11010502036488号