ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1149. Sinus Dances

what is wa 3? here is my code!
Posted by john 23 Jun 2019 02:44
#include<iostream>
using namespace std;
void sin (int n,int i)
{
    if(i==n+1)
      return ;
    else
    {
      if(i==1)
        {
          cout<<"sin("<<i;
          sin(n,i+1);
        }
      else if(i%2==1)
        {
          cout<<"+sin("<<i;
          sin(n,i+1);
        }
      else
        {
          cout<<"-sin("<<i;
          sin(n,i+1);
        }
       cout<<")";
    }

}
void sol( int n,int i)
{
  if(i==n)
    return;
  if(i==1)
    for(int i=1;i<n;i++)
      cout<<'(';
  sin(i,1);
  cout<<'+'<<n-i+1<<')';
  sol(n,i+1);

  if(i==1)
  {
    sin(n,1);
    cout<<"+1";
  }
}
int main ()
{
  int n;
  cin>>n;
  sol(n,1);
}