silent__killer1's blog

By silent__killer1, history, 5 years ago, In English

Hi ,I need to compute ncr for (n) from 1<=n<=1e9 where (n-r) are from 1<=n-r<=1e6 . Mod 1e9+7.I googling about this and get to know that this could be done by (lucas theorem) I try to implement but fails . So if anyone could help me in this it would be grateful.And please share your code for this.Thankyou.

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

By silent__killer1, history, 5 years ago, In English

Question — You are given a array of 2d coordinates , you need to find out the maximum points lie on a line. where the array length is n<=100000 I am googling alot but i found the answer only when n<=1000 which will be done in o(n^2) . Can anyone share their approach for when n<=100000. Thankyou…

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

By silent__killer1, history, 5 years ago, In English

Can anyone solve this question using Top down approach .I tried alot but not able to do it.I see alot of accepted submission using bottom up but not find any top down .Need help

Question link — https://www.codechef.com/LTIME71A/problems/CHEFRAMI

Thankyou

Full text and comments »

By silent__killer1, history, 5 years ago, In English

Hello i am just trying to solve this series 1/12 + 11/12^2 + (11*11)/12^3+...... first i need to tell you what my approach to solve which prove me wrong what i got is this is a gp so sum of finite term of gp is :Sn=a(1-r^n)/(1-r) for this series we know 0<r<1 as r comes out to be r=11/12 so consideration of this series — values come out to be a=1/12 , r=11/12 Sn=((1/12)(1-(11/12)^n)) / (1-11/12)

to compute 11^n and 12^n it take so much time with brute force so i optimize and take time log(n) now after some solving what i get is Sn=(12^n-11^n)/12^n. now n could be very large so 12^n or 11^n could be very large and we out of bounds so we need to modulo him to to get 12^n and 11^n with in the range .

lets take an example where i take n=36 my fastpower function which take less time

mod=1e9+7;

ll power(ll x,ll y){

ll te=1;

if(y==0)return 1;

te=power(x,y/2);

if(y%2==0)return (te*te)%mod;

return (te*te*x)%mod;

} int main(){

long long a=(power(12,36) - power(11,36)) / power(12,36);

} i need to find a as this is sum of finite series bu it comes out to be negative....

when i solve this i get 12^36 <11^36 and gives me finite sum of this series negative ans

Sn=(12^n-11^n)/12^n as 12^n<11^n Sn =-ve i have got i really didnt know how to solve after that i just need this series in p/q form and i need to take multiplicaive inverse of q which is later thing but first i need to solve this series and get the p/q form

someone help me out..... thankyou....

Full text and comments »

  • Vote: I like it
  • +21
  • Vote: I do not like it

By silent__killer1, history, 5 years ago, In English

You are given an array A of n integers.The value of this array is defined as the sum of absolute value of differnce of consecutive elements in the array. Example |a2-a1|+|a3-a2|+.....|an-an-1|.you are allowed to select any subarray and reverse it.You can perform this operation only once.find the max value of the array achievable.

n=no of elements in an array. ex- n=5

2 3 1 5 4 ans-10

n=7

2 4 9 24 2 1 10 ans-68

question link--https://imgur.com/a/sRq1LTg

i really didnt get how to do that please anyone ...

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it