×

# Problem in CHMOD question !!

 0 I have used precalculation technique . For ex. let 1 2 3 4 5 be array . Then through precomputation i have made another array . 1 2 6 24 120 . After that in order to cal any query it is :- arra[m]/arr[l-1] where l is lower rage and m is upper .. Is my approach wrong.. getting WA many times Could someone help me out. Solution is :- http://www.codechef.com/viewsolution/6845308 asked 08 May '15, 01:31 46●1●5 accept rate: 16%

 0 Read the constraints again. A[i]<=100; If all elements of the array are 100, the product of N such elements of the array will be: 100X100X100...100(N times)=(100)^N This will quickly overflow for large values of N as maximum value of long long int is 10^18. Therefore you need to implement multiplication between two numbers by adding their prime powers and then calculating (a^b)%c using fast squaring. answered 08 May '15, 07:24 333●2●3●9 accept rate: 20%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2
×1

question asked: 08 May '15, 01:31

question was seen: 312 times

last updated: 08 May '15, 07:24