A - Higher Math (LightOJ - 1053)

- 题目大意

给出三个数判断能否构成一个直角三角形。

- 解题思路

直接用勾股定理判断即可。(注意输出格式!!!)

- 代码

#include<iostream>
using namespace std;
int main()
{
	long long n, a, b, c;
	cin >> n;
	for (int i = 0; i<n; i++)
	{
		cin >> a >> b >> c;
		cout << "Case " << i + 1 << ": ";
		if ((a*a +b*b==c*c) || (a * a + c * c == b * b) || (b * b + c * c == a * a))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}

  

原文地址:https://www.cnblogs.com/alpacadh/p/8431235.html

时间: 2024-10-06 23:18:27

A - Higher Math (LightOJ - 1053)的相关文章

hdu 2393 Higher Math

Higher Math                                                                                  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)                                                                          

hdu 2393:Higher Math(计算几何,水题)

Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2219    Accepted Submission(s): 1219 Problem Description You are building a house. You'd prefer if all the walls have a precise right

HDU 2393 Higher Math (判断直角三角形)

题意:给定三个边,判断是不是直角三角形. 析:水题,勾股定理... 代码如下: #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <vector> #include <cstring> #include <map> using namespace std; const int maxn = 100; in

lightoj Beginners Problems

很多以前写的丑代码 1000 - Greetings from LightOJ #include<math.h> #include<stdio.h> #include<stdlib.h> #include<string.h> int main(void) { int a,b,n,Case; scanf("%d",&n); Case=0; while(Case++,n--) { scanf("%d%d",&

LightOJ Beginners Problems 部分题解

相关代码请戳 https://coding.net/u/tiny656/p/LightOJ/git 1006 Hex-a-bonacci. 用数组模拟记录结果,注意取模 1008 Fibsieve's Fantabulous Birthday. 找规律题,左边列是1 3平方 5平方......下边行是1 2平方 4平方......,找到当前数被包夹的位置,然后处理一下位置关系,注意奇偶. 1010 Kinghts in Chessboard. 规律题,对于m,n大于2的情况下,使用交叉放置的方法

light oj Beginners Problems

很多以前写的丑代码 1000 - Greetings from LightOJ #include<math.h> #include<stdio.h> #include<stdlib.h> #include<string.h> int main(void) { int a,b,n,Case; scanf("%d",&n); Case=0; while(Case++,n--) { scanf("%d%d",&

fanyi1

This article was downloaded by: [130.108.121.217]On: 07 October 2014, At: 02:50Publisher: RoutledgeInforma Ltd Registered in England and Wales Registered Number: 1072954Registered office: Mortimer House, 37-41 Mortimer Street, London W1T 3JH,UKMarria

LightOj 1078 Basic Math

思路: 设输入的两个数分别为n和a,每一次所得到的数为update: 开始update=a,依次update分别为update*10+a,这样数据会超出范围,则update每次为update=(update*10+a)%n即可, 如果update=0,跳出循环: 只需证明:(update*10+a)%n=(update%n*10+a)%n即可: 由(update*10+a)%n=(update%n*10+a%n)%n,因为a<=n,所以a%n=a.证必: 1078 - Integer Divis

LightOj 1148 Basic Math

1148 - Mad Counting PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: 32 MB Mob was hijacked by the mayor of the Town "TruthTown". Mayor wants Mob to count the total population of the town. Now the naive approach to this pro