Ural 1149 - Sinus Dances
Let An = sin(1–sin(2+sin(3–sin(4+…sin(n))…)
Let Sn = (…(A1+n)A2+n–1)A3+…+2)An+1
For given N print SN
Let Sn = (…(A1+n)A2+n–1)A3+…+2)An+1
For given N print SN
Input
One integer N. 1 ≤ N ≤ 200
Output
Line containing SN
Sample
input | output |
---|---|
3 |
((sin(1)+3)sin(1–sin(2))+2)sin(1–sin(2+sin(3)))+1 |
Problem Author: Vladimir Gladkov
Problem Source: Ural Collegiate Programming Contest, April 2001, Perm, Test Round
Problem Source: Ural Collegiate Programming Contest, April 2001, Perm, Test Round
// Ural Problem 1149. Sinus Dances // Verdict: Accepted // Submission Date: 15:58:23 15 Jan 2014 // Run Time: 0.093s // // 版权所有(C)acutus (mail: acutus@126.com) // 博客地址:http://www.cnblogs.com/acutus/ // [解题方法] // 简单字符串处理 // 注意:所有符号之间没有空格 #include<stdio.h> void An(int n) { int i; for(i = 1; i < n; i++) { printf("sin(%d", i); if(i%2) printf("-"); else printf("+"); } printf("sin(%d", n); for(i = 1; i <= n; i++) { printf(")"); } } void Sn(int n) { int i; for(i = 1; i < n; i++) { printf("("); } for(i = 1; i < n; i++) { An(i); printf("+%d)", n - i + 1); } An(n); printf("+1\n"); } void solve() { int N; scanf("%d", &N); Sn(N); } int main() { solve(); return 0; }
作者:acutus
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.