-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathPower.java
41 lines (40 loc) · 1.19 KB
/
Power.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;
/**
* @date 14/01/19
* @author SPREEHA DUTTA
*/
import java.util.*;
public class Power {
public static void main(String []args)
{
Scanner sc=new Scanner(System.in);
int n,p;int i,j;int k=0;
System.out.println("Enter size of the array ");
n=sc.nextInt();
ArrayList<Integer> arr1 = new ArrayList<Integer>(n);
ArrayList<Integer> arr2 = new ArrayList<Integer>(n);
System.out.println("Enter elements of the first array ");
for(i=0;i<n;i++)
arr1.add(sc.nextInt());
System.out.println("Enter elements of the second array ");
for(i=0;i<n;i++)
arr2.add(sc.nextInt());
System.out.println("Enter power");
p=sc.nextInt();
for(i=0;i<n;i++)
{
int t=(int)(Math.pow(arr1.get(i),p));
if(arr2.contains(t))
k++;
}
if(k==n)
System.out.println("true");
else
System.out.println("false");
}
}