24 hour archive: Problem
1650  Cos(NA) 1650  Cos(NA) 1650  Cos(NA)
Statistics  Sub: 97  AC: 53  AC%: 54,64  Score: 2,33 
Created by  Xtreme Programming Problem Archive  Jorge Amado Soria Ramírez 
Added by  ymondelo20 (20111206) 
Limits 
Total Time: 500 MS
Memory: 62 MB  Output: 64 MB  Size:
29 KB

Enabled languages  
Available in 
Description
May be you know the Cosine's Law.
But, have you ever looked at formula of the form Cos(NA)?
If you haven't looked at them yet, just look at them now:
Cos(3A) = 4Cos^3(A)3Cos(A)
Cos(4A) = 8Cos^4(A)8Cos^2(A)+1
These formula will make you believe that any Cos(NA) can be expanded in an expression which contains only one function Cos(A) and all the coefficients are also integers. In this problem your job is to find such a formula for Cos(NA) given the value of N.
May be you know the Cosine's Law.
But, have you ever looked at formula of the form Cos(NA)?
If you haven't looked at them yet, just look at them now:
Cos(3A) = 4Cos^3(A)3Cos(A)
Cos(4A) = 8Cos^4(A)8Cos^2(A)+1
These formula will make you believe that any Cos(NA) can be expanded in an expression which contains only one function Cos(A) and all the coefficients are also integers. In this problem your job is to find such a formula for Cos(NA) given the value of N.
May be you know the Cosine's Law.
But, have you ever looked at formula of the form Cos(NA)?
If you haven't looked at them yet, just look at them now:
Cos(3A) = 4Cos^3(A)3Cos(A)
Cos(4A) = 8Cos^4(A)8Cos^2(A)+1
These formula will make you believe that any Cos(NA) can be expanded in an expression which contains only one function Cos(A) and all the coefficients are also integers. In this problem your job is to find such a formula for Cos(NA) given the value of N.
Input specification
The input file contains at most 100 lines of inputs. Each line contains a positive integer N (1 <= N <= 50). Input is terminated by a line containing a single zero.
;jsessionid=FB5747DA3AB5F47569DF76458397101FThe input file contains at most 100 lines of inputs. Each line contains a positive integer N (1 <= N <= 50). Input is terminated by a line containing a single zero.
;jsessionid=FB5747DA3AB5F47569DF76458397101FThe input file contains at most 100 lines of inputs. Each line contains a positive integer N (1 <= N <= 50). Input is terminated by a line containing a single zero.
;jsessionid=FB5747DA3AB5F47569DF76458397101FOutput specification
You don't need to print any redundant things in the output such as:
(a) Printing operators in two consecutive places.
(b) Printing the coefficient when it is 1.
(c) Printing the exponent when it is 1.
(d) Just look at the output for details.;jsessionid=FB5747DA3AB5F47569DF76458397101F
You don't need to print any redundant things in the output such as:
(a) Printing operators in two consecutive places.
(b) Printing the coefficient when it is 1.
(c) Printing the exponent when it is 1.
(d) Just look at the output for details.;jsessionid=FB5747DA3AB5F47569DF76458397101F
The input file contains at most 100 lines of inputs. Each line contains a positive integer N (1 <= N <= 50). Input is terminated by a line containing a single zero.
;jsessionid=FB5747DA3AB5F47569DF76458397101FSample input
1
2
3
4
0
Sample output
Cos(A)
2Cos^2(A)1
4Cos^3(A)3Cos(A)
8Cos^4(A)8Cos^2(A)+1