Submission #25836

#TimeUsernameProblemLanguageResultExecution timeMemory
25836gs14004Palindrome-Free Numbers (BOI13_numbers)C++11
Compilation error
0 ms0 KiB
#include <cstdio> #include <algorithm> typedef long long lint; lint piv; lint pow[20]; lint dp[20][11][11][2]; lint naive_calc(int d, int p1, int p2, int isroot){ if(d == -1) return 1; if(dp[d][p1][p2][isroot]) return dp[d][p1][p2][isroot]; lint ret = 0; for (int i=0; i<10; i++) { if(isroot && i ==0) continue; if(i != p1 && i != p2){ ret += naive_calc(d-1,p2,i,0); } } return dp[d][p1][p2][isroot]=ret; } lint buho_calc(int d, int p1, int p2, int isroot){ if(d == -1) return 1; lint ret = 0; for (int i=0; i<10; i++) { if(isroot && i == 0) continue; if((piv / pow[d]) % 10 < i) break; if(i != p1 && i != p2){ if((piv / pow[d])%10 == i){ ret += buho_calc(d-1,p2,i,0); break; } else ret += naive_calc(d-1,p2,i,0); } } return ret; } lint f(lint x){ if(x == -1) return 0; piv = x; lint ret = 0; int i, lim = (int)(std::lower_bound(pow,pow+19,x+1) - pow); for (i=0; i<lim; i++) { ret += naive_calc(i-1,10,10,1); } ret += buho_calc(lim-1,10,10,1); return ret; } int main(){ lint a,b; pow[0] = 1; for(int i=1; i<19; i++) pow[i] = pow[i-1] * 10; scanf("%lld %lld",&a,&b); printf("%lld",f(b) - f(a-1)); }

Compilation message (stderr)

numbers.cpp:6:12: error: 'lint pow [20]' redeclared as different kind of symbol
 lint pow[20];
            ^
In file included from /usr/include/features.h:367:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h:482,
                 from /usr/include/c++/5/cstdio:41,
                 from numbers.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:153:1: note: previous declaration 'double pow(double, double)'
 __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
 ^
numbers.cpp: In function 'lint buho_calc(int, int, int, int)':
numbers.cpp:28:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
         if((piv / pow[d]) % 10 < i) break;
                        ^
numbers.cpp:28:24: error: invalid operands of types 'lint {aka long long int}' and 'double(double, double) throw ()' to binary 'operator/'
numbers.cpp:30:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
             if((piv / pow[d])%10 == i){
                            ^
numbers.cpp:30:28: error: invalid operands of types 'lint {aka long long int}' and 'double(double, double) throw ()' to binary 'operator/'
numbers.cpp: In function 'lint f(lint)':
numbers.cpp:44:49: warning: pointer to a function used in arithmetic [-Wpointer-arith]
     int i, lim = (int)(std::lower_bound(pow,pow+19,x+1) - pow);
                                                 ^
numbers.cpp:44:59: error: ISO C++ forbids using pointer to a function in subtraction [-fpermissive]
     int i, lim = (int)(std::lower_bound(pow,pow+19,x+1) - pow);
                                                           ^
numbers.cpp: In function 'int main()':
numbers.cpp:55:10: warning: pointer to a function used in arithmetic [-Wpointer-arith]
     pow[0] = 1;
          ^
numbers.cpp:55:12: error: assignment of function 'double pow(double, double)'
     pow[0] = 1;
            ^
numbers.cpp:55:12: error: cannot convert 'int' to 'double(double, double) throw ()' in assignment
numbers.cpp:56:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
     for(int i=1; i<19; i++) pow[i] = pow[i-1] * 10;
                                  ^
numbers.cpp:56:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
     for(int i=1; i<19; i++) pow[i] = pow[i-1] * 10;
                                             ^
numbers.cpp:56:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
numbers.cpp:56:49: error: invalid operands of types 'double(double, double) throw ()' and 'int' to binary 'operator*'
     for(int i=1; i<19; i++) pow[i] = pow[i-1] * 10;
                                                 ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/algorithm:61,
                 from numbers.cpp:2:
/usr/include/c++/5/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = double (*)(double, double) throw (); _Value = const long long int]':
/usr/include/c++/5/bits/stl_algobase.h:975:14:   required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = double (*)(double, double) throw (); _Tp = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_val]'
/usr/include/c++/5/bits/stl_algobase.h:1009:32:   required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = double (*)(double, double) throw (); _Tp = long long int]'
numbers.cpp:44:55:   required from here
/usr/include/c++/5/bits/predefined_ops.h:55:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
       { return *__it < __val; }
                      ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/5/algorithm:61,
                 from numbers.cpp:2:
/usr/include/c++/5/bits/stl_iterator_base_funcs.h: In instantiation of 'typename std::iterator_traits<_Iterator>::difference_type std::__distance(_RandomAccessIterator, _RandomAccessIterator, std::random_access_iterator_tag) [with _RandomAccessIterator = double (*)(double, double) throw (); typename std::iterator_traits<_Iterator>::difference_type = long int]':
/usr/include/c++/5/bits/stl_iterator_base_funcs.h:117:29:   required from 'typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator) [with _InputIterator = double (*)(double, double) throw (); typename std::iterator_traits<_Iterator>::difference_type = long int]'
/usr/include/c++/5/bits/stl_algobase.h:968:42:   required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = double (*)(double, double) throw (); _Tp = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_val]'
/usr/include/c++/5/bits/stl_algobase.h:1009:32:   required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = double (*)(double, double) throw (); _Tp = long long int]'
numbers.cpp:44:55:   required from here
/usr/include/c++/5/bits/stl_iterator_base_funcs.h:96:21: error: ISO C++ forbids using pointer to a function in subtraction [-fpermissive]
       return __last - __first;
                     ^
numbers.cpp:57:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&a,&b);
                             ^