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:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.9.2, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.4, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions