Timus 1149. Sinus dances

Source: Internet
Author: User

Timus 1149. Sinus dances requires that strings in specific formats be output.

1149. Sinus dancestime limit: 1.0 second
Memory limit: 16 mblet An= Sin (1-sin (2 + sin (3-sin (4 +... Sin ( N))...)
Let Sn= (... ( A1 + N) A2 + N-1) A3 +... + 2) An+ 1
For given NPrint SnInputone integer N. 1 ≤ NLess than or equal to 200 outputline containing SnSample
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, limit L 2001, Perm, test round

Tags:Problem for beginners

C # language:

Using system; // http://acm.timus.ru/problem.aspx? Space = 1 & num = 1149 static class timus {const int max = 200; static char [] MSG = "Sin () + -". tochararray (); static char [] A = new char [Max * 10]; static char [] S = new char [Max * 5 * max]; static void main () {console. writeline (S, 0, makes (Int. parse (console. readline ();} static int makes (int n) {var COUNT = 0; while (count <n-1) s [count ++] = MSG [3]; // '(' For (int K, I = 1; I <= N; I ++, Count ++) {Var n = (n-I + 1 ). tostring (). tochararray (); array. copy (A, 0, S, Count, K = makea (I); // AI s [count + = K] = MSG [5]; // '+' array. copy (n, 0, S, ++ count, N. length); // n-I + 1 s [count + = n. length] = MSG [4]; // ')'} return -- count; // remove the last ')'} static int makea (int n) {var COUNT = 0; for (VAR I = 1; I <= N; I ++, Count ++) {var n = I. tostring (). tochararray (); array. copy (MSG, 0, A, Count, 4 ); // "Sin (" array. copy (n, 0, A, Count + = 4, N. length); // I A [count + = n. length] = MSG [(I % 2 = 0 )? 5: 6]; // '+' or '-'} count --; // overwrite the last '+' or '-' For (VAR I = 0; I <N; I ++) A [count ++] = MSG [4]; // ') 'Return count ;}}

This question and answer are very simple and I will not explain it.

Returned directory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.