1 solutions

  • 0
    @ 2024-12-10 22:16:31

    C :

    #include<stdio.h>
    int kalante(int x){
    	if (x == 1) return 1;
    	else {
    		return (4 * x - 2)*kalante(x - 1) / (x + 1);
    	}
    }
    int main(){
    	int n;
    		while (scanf("%d", &n) != EOF){
    			printf("%d\n", kalante(n));
    		}
    		return 0;
    }
    

    C++ :

    #include<iostream>
    using namespace std;
    int n,ans=0;
    void work(int l,int m,int r)
    {
    	if(!l&&!m&&r==n){ans++;return;}
    	if(l>0)work(l-1,m+1,r);
    	if(m>0)work(l,m-1,r+1);
    }
    int main()
    {
    	ios::sync_with_stdio(false);
    	cin>>n;
    	work(n,0,0);
    	cout<<ans<<endl;
    	return 0;
    }
    
    • 1

    Information

    ID
    535
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By