Download spoj_cpp_clean/ACODE/ACODE-13.cpp from slayone/uva_spoj_raw: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/spoj_cpp_clean/ACODE/ACODE-13.cpp
- Command line
-
hf download hf://datasets/slayone/uva_spoj_raw/spoj_cpp_clean/ACODE/ACODE-13.cpp
-
curl -L -o ACODE-13.cpp https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/spoj_cpp_clean/ACODE/ACODE-13.cpp
1.51 kB
| typedef long long i64; | |
| template <class T> void make_unique(T& v) {sort(all(v)); v.resize(unique(all(v)) - v.begin());} | |
| using namespace std; | |
| i64 memo[5001]; | |
| bool mark[5001]; | |
| char buffer[5001]; | |
| int n; | |
| i64 f(int k){ | |
| if(k >= n)return 1; | |
| if(buffer[k] == '0')return 0; | |
| i64 &count = memo[k]; | |
| if(mark[k])return count; | |
| mark[k] = true; | |
| count = f(k+1); | |
| if((buffer[k] == '1' || buffer[k] == '2') && k+2 <= n) | |
| count += f(k+2); | |
| return count; | |
| } | |
| int main(){ | |
| freopen("data.in","r",stdin); | |
| while(scanf("%s", buffer) == 1 && buffer[0] != '0'){ | |
| n = strlen(buffer); | |
| memset(mark,false,sizeof(mark)); | |
| i64 res = f(0); | |
| printf("%lld\n",res); | |
| } | |
| return 0; | |
| } |