Cosine Partition Function
All submissions for this problem are available.
Chef Ciel is participating an arithmetic contest now.
Because of the top prize for the contest, limited edition chopsticks.
She must calculate the values f(M, N, X) of function named cosine partition function to be the first place.
The cosine partition function f(M, N, X) is defined by
Examples are following:
f(1, 3, X) = cos(3X/3) = cos(X)
f(2, 3, X) = cos(0/3) cos(3X/3) + cos(X/3) cos(2X/3) + cos(2X/3) cos(X/3) + cos(3X/3) cos(0/3) = 2 cos(X/3) cos(2X/3) + 2 cos(X)
f(3, 1, X) = cos(0) cos(0) cos(X) + cos(0) cos(X) cos(0) + cos(X) cos(0) cos(0) = 3 cos(X)
Ciel is a great chef, however she is not good at arithmetic.
For given M, N and X, your work is calculating the value of f(M, N, X).
The first line contains an integer T, the number of test cases.
Then T test cases follow.
Each test case has 2 integers M, N and a real number X.
X has at most two digits after the decimal point.
For each test case, print the value of f(M, N, X).
This value must have an absolute or relative error no more than 10-6.
You can safely assume the magnitude of the answer is at most 10300.
1 <= T <= 50
1 <= M <= 1000000000 (10^9)
1 <= N <= 30
0 <= X <= 1
4 1 3 1.0 2 3 0 30 1 0.1 1 1 0.5
0.5403023059 4.0000000000 29.8501249583 0.8775825619
|Tags||laycurse, march12, medium|
|Time Limit:||0.245455 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions