Download spoj_cpp_clean/ACODE/ACODE-11.cpp from slayone/uva_spoj_raw: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/spoj_cpp_clean/ACODE/ACODE-11.cpp
- Command line
-
hf download hf://datasets/slayone/uva_spoj_raw/spoj_cpp_clean/ACODE/ACODE-11.cpp
-
curl -L -o ACODE-11.cpp https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/spoj_cpp_clean/ACODE/ACODE-11.cpp
1 kB
| /* | |
| * Written by Nitin Kumar Maharana | |
| * nitin.maharana@gmail.com | |
| */ | |
| using namespace std; | |
| string input; | |
| map<int, unsigned long long> memory; | |
| map<int, unsigned long long>::iterator it; | |
| int len; | |
| unsigned long long findNumDecoding(int index) | |
| { | |
| if(index == len || index == len-1) | |
| return 1ull; | |
| it = memory.find(index); | |
| if(it != memory.end()) | |
| return (it->second); | |
| unsigned long long result; | |
| if(input[index] > '2' || (input[index] == '2' && input[index+1] > '6') || (index+2 < len && input[index+2] == '0')) | |
| result = findNumDecoding(index+1); | |
| else if(input[index+1] == '0') | |
| result = findNumDecoding(index+2); | |
| else | |
| result = (findNumDecoding(index+1) + findNumDecoding(index+2)); | |
| memory.insert(make_pair(index, result)); | |
| return result; | |
| } | |
| int main(void) | |
| { | |
| cin >> input; | |
| while(input != "0") | |
| { | |
| len = input.length(); | |
| cout << findNumDecoding(0) << endl; | |
| input.clear(); | |
| memory.clear(); | |
| cin >> input; | |
| } | |
| return 0; | |
| } |