Help Nishant Problem

 Nishant does pretty weird stuff. Today, he wants to create a weird sequence.  According to Nishant, a sequence A of length N is called weird if:  N≥3 2⋅Ai>Ai−1+Ai+1 ∀i∈{2,3,4....,N−1} Nishant wants to construct a long weird sequence to impress his weird friends, but there's a problem: he only knows how to count up to K, so the sequence can only contain integers in the range [1,K].  Help Nishant determine the length of the longest weird sequence he can construct using only integers from 1 to K.







OURSHOPKEEPER













#include <iostream>
// #include <bits/stdc++.h>
#include <stdio.h>
using namespace std;

#define ll long long
#define FAST1 ios_base::sync_with_stdio(false);
#define FAST2 cin.tie(NULL);
//  #define s  for (val = 1; val <= k; val++)
#define p scanf("%lld", &k);
#define z scanf("%lld", &t);
#define u while (t--)
#define y long long int
#define pp solve()
#define rr ll int recu(int k, int ct, int val)
#define w if (k >= val)
#define g k = k - val
#define red return ct;
#define h ct += 2
#define ti val + 1
#define q k = k - 1;
#define v ll newu = recu(k, ct, val);
#define dos return recu(g, h, ti);
#define r printf("%lld\n", newu);

rr
{
    w
        //  if (k >= val)
        {
            // printf("%lld\n", ct);
            // cout << "\n";
            // return ct;
            dos
            //  return recu(g, h, ti);
        } red
    //  return ct;
    // printf("%lld\n", ct);
}

void pp
{

    y k;

    // cin >> k;
    p
        y ct = 2,
          val = 1;

    q
        // k =k- 1;
        v
            //    ll newu = recu(k, ct, val);

            //   k = k- val;

            //   ct += 2;

            // cout<<ct<<endl;
            r
    // printf("%lld\n", newu);
}

int main()
{

    FAST1;

    FAST2;

    y t = 1;
    z
        //  scanf("%lld", &t);
        //   cin >> t;

        //
        u
    {

        pp;
    }
}






    


Click on the above button to download the code.



Post a Comment

If you have furthur QUERIES please let us know

Previous Post Next Post