ETFS - Euler Totient Function Sieve

Leonhard Euler Totient

In number theory, the totient phi(n) of a positive integer n is defined to be the number of positive integers less than or equal to n that are coprime to n.

Input

The lonely line in input contains two integers a, b.

Output

Print phi(n) for n from a to b (inclusive).

Example

Input:
1 5

Output:
1
1
2
2
4

Constraints

0 < a < b < 10^14
b - a < 10^5

Python can get AC under half the time limit (for any test case). My total PY3.4 time is 3.23s for 5 input files.
Have fun ;-)


Added by:Francky
Date:2014-12-29
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:ETF

hide comments
2016-03-30 13:39:47
lolypop question
2015-11-11 11:50:20 :.Mohib.:
Finally did it.... :)

Last edit: 2015-11-11 12:05:11
2015-09-06 10:15:38 Parul Yadav
finally AC... feeling good
2015-06-23 17:22:15 Diksha Jaiswal
quite a learning problem for me (y) :)
2015-04-12 19:47:16 Daksh
Accepted... :) nice problem...

Last edit: 2015-04-13 07:17:54
2015-01-17 17:01:38 Kid Algorist
Easily understood tricky questions are the best.
Big ups to Francky.
Hope to see many more such questions in the future.

To those getting TLEs and WAs, Don't give up, this question is well worth it.

--francky--> Thanks for the appreciation. I really appreciate.

--Cheers.

Last edit: 2015-01-18 17:49:08
2015-01-02 16:06:20 Walid Amin
this problem really taught me how to use sieve in other problems other than generating primes :D
NICE PROBLEM

--francky--> Thanks for the appreciation.

Last edit: 2015-01-02 16:20:29
2014-12-30 12:36:26 rahul goyal
okkk...got it (y)..
thankss..
2014-12-30 12:17:53 rahul goyal
example output should be
1
2
3
4
??? explain this?

--ans(Francky)--> Firstly, it's from 1 to 5 inclusive, so 5 numbers are awaited. Then we have the well known values phi(1)=1, phi(2)=1, phi(3)=2, phi(4)=2 and phi(5)=4. See ETF : the example is exactly the same.

Last edit: 2014-12-30 12:25:47
2014-12-30 12:17:00 Yashpal
AC in 0.22s !!
@Francky Please see my best solution Could I make more optimization ??
By the way nice combination of two problems PRIME1 and ETF ! :P

Last edit: 2014-12-30 13:08:58
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.