Submit | All submissions | Best solutions | Back to list |
DCEPC804 - Totient Fever |
Another Totient problem by Ankur Sir J. He is madly in love with totient. Let’s see what he has prepared this time.
Recently he was studying integral properties of Quadratic functions. He found some interesting notions of real and complex numbers through Quadratic functions. But as you know he is a big totient fan, he mixed totient with quadratic functions this time and that resulted into a nice problem. He wants to find out if there exists a real root ‘x’ in the equation below:
Totient(a*x^2 + b*x + c) = k
Given ‘a’, ‘b’, ‘c’ and ‘k’, output “Yes” if a real root exists or “No” if no real root exists.
Input
First line contains T, the no. of test cases.
Each of the next T lines contains a, b, c and k.
Output
Output T lines, each for a single test case, containing either a “Yes” or a “No” corresponding to the test case.
Constraints
0 < T <= 100
0 < a <= 10^6
0 < b <= 10^6
0 < c <= 10^6
0 < k <= 10^6
b^2 >= 4*a*c
Example
Input: 2 1 4 3 4 1 21 11 10 Output: Yes Yes
Added by: | dce coders |
Date: | 2012-08-19 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | ASM32-GCC MAWK BC C-CLANG C NCSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JAVA JS-MONKEY JULIA KTLN NIM NODEJS OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 PY_NBC R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET |
Resource: | Own Problem |
hide comments
2014-05-09 11:31:04 Min_25
@Lakshman Since T is very small, another approach (which does not enumerate totient values) is faster for this problem. |
|
2014-05-09 10:43:51 [Lakshman]
@Min_25 amazing speed. Is there any direct formula or some ultra fast algorithm. |
|
2014-05-09 09:32:32 Flago
@SanchitK : I dunno if i can say that without being too "spoilly" but, n=4166250 is maximum value for T(n)=10^6 however T(n)=995328 admit n=5290740 as maximum. |
|
2014-03-27 21:17:57 SanchitK
for k=1000000, what is the maximum value of n whose totient is 1000000? |
|
2012-12-11 18:49:50 (Tjandra Satria Gunawan)(曾毅昆)
@Ehor Nechiporenko: Congratulations :-D you're faster than me for this problem... |
|
2012-10-16 09:25:49 Ehor Nechiporenko
@Tjandra, unfortunantly you are not the fastest. But thanks for your INVPHI problem, it helped me to resolve this one ;-) |
|
2012-09-27 15:10:59 (Tjandra Satria Gunawan)(曾毅昆)
Another approach, time: 0.3sec, woohoo! ;-) |
|
2012-09-27 14:18:39 (Tjandra Satria Gunawan)(曾毅昆)
Finally AC, very nice problem :-) Need 29 days for me to get the idea for solving this problem.. With efficient data structure and own idea/trick, AC in 1.3sec and use only 2.2MB of memory, and first place ;-D |