You are not logged in. Please login at www.codechef.com to post your questions!

×

Product of Divisors

Can someone tell what is wrong with my program at http://www.codechef.com/viewsolution/7091224 for the problem Product of Divisors at http://www.codechef.com/problems/D1/

asked 06 Jun '15, 02:14

agnelvishal's gravatar image

1★agnelvishal
1315
accept rate: 0%


@agnelvishal hi here is a little optimization...use squaring for last ans calculation.....where u had calculated value of a...then use squaring method to reduce little complexity and try other ...

link

answered 06 Jun '15, 04:29

rcsldav2017's gravatar image

5★rcsldav2017
1.1k1229
accept rate: 6%

edited 06 Jun '15, 07:37

Sorry but I did not understand what is squaring and where did you ask to use it.

link

answered 06 Jun '15, 09:24

agnelvishal's gravatar image

1★agnelvishal
1315
accept rate: 0%

@agnelvishal ..for calculating pow(N,a)..in log(a) complexity here is little psuedo code Complexity : O(log(POW)) #define MOD 1000000007

long long int (long long int N,long long int POW) { if(POW<=0) return 1; if(N==1) return 1; long long int ans=1; while(POW) { if(POW%2){ ans=N; POW--; if(ans>=MOD) ans%=MOD; } N=N; POW/=2; if(N>=MOD) N%=MOD; } }

link

answered 07 Jun '15, 11:43

rcsldav2017's gravatar image

5★rcsldav2017
1.1k1229
accept rate: 6%

edited 07 Jun '15, 11:44

here is my solution link...http://www.codechef.com/viewsolution/7108948

what is wrong with my solution??

can u find error??

link

answered 07 Jun '15, 11:49

rcsldav2017's gravatar image

5★rcsldav2017
1.1k1229
accept rate: 6%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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:

×266
×205
×75
×38

question asked: 06 Jun '15, 02:14

question was seen: 1,132 times

last updated: 07 Jun '15, 11:49