spoj → classical → aps → Amazing Prime Sequence

you can get the problem statement from here.

simple one,

first we have to pre-calculate the smallest factor of n array for 1 <= n <= 107

and then using those we can pre-calculate the “amazing prime sequence” for 1 <= n <= 107 in O(n)

https://gist.github.com/7befd21778545c848a55

note: don’t forget to use int64_t…. i got a wa for using int32_t

Screenshot from 2015-05-27 21:23:38

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s