Created
March 21, 2019 08:01
-
-
Save jskyzero/95be52be97b0e97983a2b824387c9847 to your computer and use it in GitHub Desktop.
Mi_Question
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<iostream> | |
// slot choice result | |
// 1 3 3 | |
// 2 3 1 3 | |
// 2 2 | |
// 3 1 | |
int f(int slot, int choice) { | |
int result = 0; | |
if (slot == 1) return choice; | |
for (int i = 0; i < choice; i++) { | |
result += f(slot - 1, choice - i); | |
} | |
return result; | |
} | |
int main() { | |
std::cout << "slot\tchoice\t" << std::endl; | |
std::cout << "1\t1\t" << f(1, 1) << std::endl; | |
std::cout << "1\t2\t" << f(1, 2) << std::endl; | |
std::cout << "1\t3\t" << f(1, 3) << std::endl; | |
std::cout << "2\t3\t" << f(2, 3) << std::endl; | |
std::cout << "3\t3\t" << f(3, 3) << std::endl; | |
std::cout << "4\t4\t" << f(4, 4) << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment