The problem goes as follows : "An array a is called beautiful if for every pair of numbers ai, aj, (i ≠ j), there exists an ak such that ak = ai * aj. Note that k can be equal to i or j too." So for n==1, there do not exist any pairs and hence the array is not supposed to be "Beautiful". But the way test cases turned out, the array was supposed to be "Not Beautiful" Kindly check into it the same. asked 22 Oct '16, 22:17

The problem clearly says that "for every pair of numbers...". For n = 1, no pair exists, hence there is no need to check for the second condition. Hence the answer is "yes" answered 23 Oct '16, 07:52

I just cannot believe this. I made 5 submissions in this questions having total faith that for n=1 the answer must be no. I guess the basic definition is being rejected "i!=j" (1st index!=1st index) answered 23 Oct '16, 11:10

As mentioned above, it's a vacuous truth statement. https://en.wikipedia.org/wiki/Vacuous_truth It uses the fact that whenever an implication p=>q is given, and if p itself is false, it doesn't matter whether q is true or not and the statement is considered true. In our case, p = "if there exists a pair", which is false for n=1, making the assertion true by default. You can also use the equivalent relation ~p+q for p=>q, meaning either of ~p or q being true for the statement to be true; This statement, when viewed in it's equivalent terms, would be read as: "If there doesn't exist any pair (i,j) OR there exists an ak..." Since the first condition holds for n=1, the statement is implicitly true. P.S I didn't know about vacuous truth statements either and I submitted the answer with a "no" as well. Learnt something new, and I hope you did too now. :) answered 23 Oct '16, 15:32

The question clearly states that "if there exists pairs and those are not beautiful then output no"..But for n=1,there are no pairs to violate the above condition... Hence the answer will be "Yes".. :) answered 23 Oct '16, 10:55

Why was time not extended????I submitted at 14 minutes left and got result when 20 seconds were left and That too a compilation error.... Should not they have extended the time by 15 minutes??????They often do it in cook off !! I missed a chance to go to Amritapuri... answered 23 Oct '16, 11:29

wow.... Great.... the intricacies of knowledge.. !! "Vacuously" ... shaandaar answered 22 Oct '16, 22:37

answer for n=1 should be "no" because it is clearly stated in question that for pair (i,j) i!=j answered 23 Oct '16, 01:02

yes . the answer should be "no" for n=1 , because we cannot have a pair (i,j) such that i!=j. Kindly look into this please. answered 23 Oct '16, 07:11

The answer for n=1, should be "no".. Vacuous True cases are when we don't have any condition that rejects the case, but here it is clearly stated that i! =j, so it is a "no" here.. Please look into this.. answered 23 Oct '16, 10:27

can anyone tell the way to solve this problem.. answered 23 Oct '16, 11:17
1
https://www.codechef.com/viewsolution/13226331 the code is readable and logic is surely easy to understand.
(09 Apr '17, 13:26)

Please review my code i am new in coding.I am getting time limit exceeded error answered 09 Apr '17, 00:32

Can SomeOne plz tell me that what is the problem with my solution. https://www.codechef.com/viewsolution/13382532 answered 24 Apr '17, 10:06

@akhii1998 The reason you got WA is because you are storing the product of a[i] & a[j] in the integer variable whereas integer limit is 2 * 10^9 and product can go about 10^18. However, that is not you should be worried about. Since you are beginner I think you are not yet aware of the term Time Complexity .( check this links or search on web to know about Time Complexity: https://www.quora.com/Whataresomeeasywaystounderstandandcalculatethetimecomplexityofalgorithms https://www.quora.com/Iamgetting%E2%80%9CTimeLimitExceeded%E2%80%9DresponseforseveralproblemsonCodechefHowshouldIoptimizemycode/answer/VaibhavTulsyan ) You are running two loops to choose a[i] and a[j] and size of the array can be upto 10^5 . Then 2 select every 2 combination you are using 10^5 Choose 2 iteration which is in the order of 10^10. And again you are linear searching , suppose the product is not present in array, then you have to again traverse 10^5 elements. So your complexity can go upto 10^15 iterations which can take years to execute because normally PC executes 10^8 to 10^9 iterations per second of C/C++ code. Hence, to reduce the time complexity you need to think about other logic, better logic than needs few number of iterations. So try your best to come up with better approach by making some observations(Use pen and notebook :P). And, if stuck can have a look at working solution here : https://www.codechef.com/viewsolution/ . Cheers , happy coding and learning . answered 24 Apr '17, 10:52

anbody can help me why my code is wrong? include<stdio.h>int main() { int a,b,c,d,k,h=0,y,i=1,j[100000]; scanf("%d\n",&a); start:scanf("%d\n",&b); d=b1; y=b; while(b!=0) {
} answered 28 Apr '17, 01:31

I have a problem with this task ! I have another solution more complicated i have tested for several examples and it works , but every time i submitt , it gives "wrong answer" , i don't know why ?!! package beginner; import java.io.; import java.util.; import java.lang.*; public class BeautifulArraysICPC16B { // static int max ; // static int min; // static int occMax ; // static int occMin ;
// if(n==1) { // out.println("no"); // }else
} answered 05 May '17, 20:27

well i have a doubt in this problem,shouldn't the array for example {1,1,2} be not beautiful as 1*2 = 2 as there is no such element therefore {1,1,2} should not be beautiful but in few of the successful submissions this array comes out to be a beautiful array and i submitted both mine(which shows the above example to be not beautiful) and the other codechef seemed to accept the other one.I think there is a problem in the solution from there end MAYBE.So pls somebody help and pls tell where i am going wrong? answered 10 May '17, 13:06

include <iostream>using namespace std; int main() { int k; cin>>k; for(int j=1;j<=k;j++) { int n; cin>>n; int a[n],sum=1,i,count=0;
} pls...Anyone look at this code...pls tell me what is wrong with this.. I an getting the correct answer in all other compilers.But code chef states it as wrong answer.. PLS HELP ANYONE..PLS..PLS..PLS.. answered 21 May '17, 18:13

answered 26 Jul '17, 00:14
1
For n=1, array is beautiful. AFter accounting for this, you will get TLE. Make some observations on when an array can be beautiful. Take an array of
These 3 will give you a direction to think.
(26 Jul '17, 00:27)

man, you gave me a shock for a minute. "But the way test cases turned out, the array was supposed to be "Not Beautiful" Kindly check into it the same." It is wrong. Test cases doesn't say that n = 1 is not beautiful. n = 1 is beautiful by definition.
An array a is called beautiful if for every pair of numbers ai, aj, (i ≠ j). There does not exist any pair in the first place, and for a n==1, we cannot have i!=j. So wouldn't the default answer for n==1 be "Not Beautiful". Didn't mean to shock you but kindly look into this.
An application of some definition should work in this way, take the definition, apply on your object (in this case array), if it violates the conditions, then the array is bad, otherwise it is good. Now, our example for n = 1, there are no two i, j such that i != j, so the array is good implicitly. This type of statements are called vacuously true.
Okay, thank you. Perfectly fine :)