SHARE
TWEET

Untitled

a guest Mar 26th, 2020 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.  long long int t,i,k,l,n,j,fib[300005],tmp,diff,sam,sum,sam2;
  5.     scanf("%lld",&t);
  6.     while (t--)
  7.     {
  8.        sum=0;
  9.         scanf("%lld%lld",&k,&n);
  10.         for(i=0;i<k;i++)
  11.         {  
  12.             fib[i]=i%1000007;
  13.             sum+=i%1000007;
  14.         }      
  15.             fib[k]=sum%1000007;
  16.             tmp=k+1;
  17.             for(i=tmp;i<n;i++)  {
  18.                /* sam=(2*fib[i-1])%1000007;
  19.                 sam2=fib[i-1-k]%1000007;
  20.                 fib[i]=(sam-sam2)%1000007;*/
  21.                 fib[i]=(2*fib[i-1]-fib[i-k-1])%1000007;
  22.             }
  23.             printf("%lld\n",fib[n-1]);      
  24.     }
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top