Download uva_cpp_clean/10018/10018-9.cpp from slayone/uva_spoj_raw: direct link, hf CLI and curl.
- Browser
- Download file 511 Bytes
-
https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10018/10018-9.cpp
- Command line
-
hf download hf://datasets/slayone/uva_spoj_raw/uva_cpp_clean/10018/10018-9.cpp
-
curl -L -o 10018-9.cpp https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10018/10018-9.cpp
511 Bytes
| using namespace std; | |
| int tc, ct; | |
| unsigned num; | |
| unsigned reversed_number(unsigned n){ | |
| unsigned pib = 0; | |
| while(n) pib = pib * 10 + n % 10, n /= 10; | |
| return pib; | |
| } | |
| void Lychrel_number(){ | |
| ct = 0; | |
| while( ct < 50 ){ | |
| ct++; | |
| num += reversed_number(num); | |
| if( num == reversed_number(num) ) break; | |
| } | |
| } | |
| int main(){ | |
| scanf("%d", &tc); | |
| while( tc-- ){ | |
| scanf("%u", &num); | |
| Lychrel_number(); | |
| printf("%d %u\n", ct, num); | |
| } | |
| return(0); | |
| } | |