AMIFIB - Editorial

@vineetpaliwal, thanks for your reply and cofirmation :slight_smile:

I will definitely e-mail codechef admins regarding this matter as soon as possible for me :smiley:

By the way, the problem was interesting and your idea for solving it was also very good :slight_smile:

Best,

Bruno

1 Like

I ran the tester’s code on my system, I am very sad to see that the output is ‘YES’ for all numbers greater than 10^64 :frowning:

1 Like

what is wrong in my solution ??

Please tell, how is checkSquare() method implemented in author’s solution? Which formulae is used to check whether a number is perfect square or not? Any link/information will be highly appreciated.
Thanks

here is simplest solution by RAJAT De

hi here is a simple code
#include <stdio.h>
 #include <string.h>
 #include<iostream>

 using namespace std;
 long long c(char *s){

 long long i,n=0;
    for(i=0;i<strlen(s);i++)
        n=10*n+s[i]-'0';
      return n;
    }

  int main()
 {

            int t;
           cin>>t;

      while(t--)
    {
      long long a[6000],i,m;
      char s[1001];
      cin>>s;
      m=c(s);

      a[0]=1;a[1]=1;

      for(i=2;i<6000;i++){
          a[i]=a[i-1]+a[i-2];
          if(a[i]==m){
             cout<<"YES"<<endl;
             break;
          }
         if(i==5999){
          cout<<"NO"<<endl;
        }
    }
   }
   return 0;
 }

HAPPY CODING
can anyone explain how it does work with long string

hey,can anyone tell me the error in the code, i am using property 5nn + 4 or 5nn - 4 or both are perfect square to solve it .CodeChef: Practical coding for everyone

For those who are saying this question was biased towards JAVA, Well then I solved this problem in C++ in 5 minutes CodeChef: Practical coding for everyone and make sure you save my template so that you can do the BIGINTEGER stuff in c++ using strings.

@sikander_nsit, questions are not language dependent, some languages have advantages over others depending on the case. Competitors will always try and take advantage of their languages features.

1 Like

@junior94 By language dependent I meant the same thing as one language being advantageous than other. My point was that a beginner who uses C/C++ would not have been able to solve this question. This should not be the case for the first(easiest) question in the contest.

4 Likes

testers solution says 10256117644121029666 is a fibonacci no. but it isnt!

1 Like

ya definately there is something wrong with test cases !!

He is just doing the operations in a unsigned long long, so when ever over flow occurs he is JUST ALLOWING IT. It is equal to performing calculations modulo 2^64.

No, his solution is wrong. It says 10256117644121029666 is a fibonacci no., but it is not.

Your code link: WMDHVe - Online Python Interpreter & Debugging Tool - Ideone.com
Tester code link: GLjOzF - Online C++0x Compiler & Debugging Tool - Ideone.com

1 Like

In the tester’s solution the mx limit upto which the fib sequence is calculated is taken as 6666.Is it just some random limit and if not then how’d we arrive to the no 6666.Someone please explain me the logic behind this.

Tester’s solution also gives wrong answer for 10256117644121029666 which is not a fibonacci number.

admin please answer!!!

@junior94 this is not a platform to test language skills. If algorithmic skills were to be tested, the limits would have been within 10^18.

1 Like

@rishul_nsit, I didn’t say it was a platform to test language skills, I only said that users usually take advantage of their language features. In cook offs it’s always better to do a task in the shortest way possible. I won’t deny that python and java had a significant advantage over C and C++ but this is not the first time that a question regarding BigInteger is appearing and possibly not the last either. But I must agree with @sikander_nsit statement too, for one of the easiest problems in the cook off, it required a significant amount of coding.

Can you explain how the tester is storing 1000 digit numbers into a set of unsigned long long !

3 Likes

@junior94 what I meant was such questions should appear in Long contests and not the cook offs