Created
September 16, 2019 10:22
-
-
Save ray1422/462b8125cbed1b9fe1ed46b430902101 to your computer and use it in GitHub Desktop.
Green Judge b024
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
long long int fa(long long int n) { | |
long long int sum = n; | |
for(int i = 1;i < n; i++) { | |
sum *= i; | |
} | |
return sum; | |
} | |
long long int c(int m, int n) { | |
if(n > (m - n)) n = m - n; | |
if (n == 0) return 1; | |
long long int total = 1; | |
for(int i = 0; i < n; i++) { | |
total *= (m - i); | |
} | |
total = total / fa(n); | |
return total; | |
} | |
int main() { | |
long long int n; | |
long long int num_method = 0; | |
cin >> n; | |
for(int num_double_step = 0; (num_double_step * 2) <= n; num_double_step++) { | |
int num_single_step = n - (num_double_step * 2); | |
int total_step = num_single_step + num_double_step; | |
num_method += c(total_step, num_single_step); | |
} | |
cout << num_method << " "; | |
n = num_method % n; | |
num_method = 0; | |
for(int num_double_step = 0; (num_double_step * 2) <= n; num_double_step++) { | |
int num_single_step = n - (num_double_step * 2); | |
int total_step = num_single_step + num_double_step; | |
num_method += c(total_step, num_single_step); | |
} | |
cout << num_method; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment