首页 > 代码库 > ural 1149. Sinus Dances

ural 1149. Sinus Dances

技术分享

 

就是找规律:

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 using namespace std;
 5 
 6 
 7 void AN(int n){
 8      printf("sin(");
 9     for(int i=1;i<=n;i++){
10         if(i==1)
11             cout<<1;
12         else{
13             printf("%c",i&1?+:-);
14             printf("sin(%d",i);
15 
16         }
17     }
18     for(int i=1;i<=n;i++)
19         putchar());
20 
21 }
22 
23 void SN(int n){
24     for(int i=1;i<n;i++)
25         cout<<"(";
26     for(int i=1;i<=n;i++){
27         if(i!=1) cout<<")";
28         AN(i);
29         putchar(+);
30         cout<<n-i+1;
31     }
32     cout<<endl;
33 }
34 
35 int main(){
36     int n;
37     cin>>n;
38     SN(n);
39 }

 

ural 1149. Sinus Dances