Fazil the tutor of the skill training institute gave an array of integers to one of highly attentive student of his class Rohan and asked him create a programming snippet to find the Pythagorean triplet that satisfies
a2 + b2 = c2.
Rohan is trying hard to impress his tutor Fazil but he is finding it difficult to complete the task.
Can you help Rohan in completing the task?
Input:
The first line contains T, denoting the number of testcases. Then follows description of testcases.
Each case begins with a single positive integer N denoting the size of array.
The second line contains the N space separated positive integers denoting the elements of array A.
Output:
For each testcase, print "Yes" it is Pythagorean Triplet and "No" if not.
#include<stdio.h> #include<stdlib.h> #include<math.h> int a[10000000]; int b[10000000]; extern int Triplet(int ar[],int n); int main(){ int t; scanf("%d",&t); while(t--){ int n; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a[i]); a[i]=a[i]*a[i]; } Triplet(a,n); } return 0; } int Triplet(int ar[],int n) { int k=0,i,j,flag=0; for(i=0;i<n-1;i++){ for( j =i+1;j<n;j++){ b[k]=a[i]+a[j]; k++;} } for(i=0;i<n;i++){ int x=0; for(x=0;x<=k;x++){ if(a[i]==b[x]){ printf("Yes\n"); flag=1; break;} } } if(flag==0){ printf("No\n");} }
INPUT_1:
3
5
85 64 132 189 157
6
87 35 6 10 4 12
7
96 110 247 94 15 9 265
OUTPUT:
Yes
No
Yes
INPUT_2:
4
4
25 3 9 13
8
104 129 451 153 103 185 181 341
6
161 124 139 240 112 289
5
117 55 16 33 130
OUTPUT:
No
Yes
Yes
No
ILLUSTRATION
![](http://www.fcukthecode.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-02-20-38-54.png)
Morae Q!
- Find the number of strings made by using each alphabet as starting character.
- Find the Pythagorean triplet.
- Find out what is the minimum possible energy he needs to spend.
- Sort the array in non-decreasing order and print out the original indices of sorted array.
- Compute the number of landmasses on the planet after all the meteorites have fallen.
- Give the appropriate server status as output.
- Regular expressions (Regex) using search module in python.
- Find the minimum distance between any pair of equal elements in the array.
- Find the total number of matching pairs of socks that are available.
- Find the total number of teams which can work together and cannot work together.
- Given the heights of all the boys and girls tell whether it is possible for all boys to get a girl.
- Find the sequence of cities to visit according to coordinates and conditions.
- Find the number of unique patches of rectangular land to grow samba(rice) in.
- Regular expression Regex matching strings.
- Generate a greeting quote for admin.
- Find all the cavities on the map and replace their depths with the character X.
- Check whether the given graph is Bipartite or not.
- Find the status of the passengers and safari cars at zoo after k units of time.
- Determine the chair number occupied by the child who will receive that chocolate.
- Check if Rubik’s cube of any dimensions can be assembled.