Submission #75269

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
752692018-09-09 04:53:06SherazinPalindrome-Free Numbers (BOI13_numbers)C++14
100 / 100
3 ms1144 KiB
#include <bits/stdc++.h>
using namespace std;
long long a, b, ans;
long long dp[20][15][15][2][2];
char A[20];
long long solve(int pos = 0, int a = 10, int b = 10, int f = 0, int st = 1) {
if(!A[pos]) return 1LL;
long long &ret = dp[pos][a][b][f][st];
if(~ret) return ret;
ret = 0;
int lim;
if(!f) lim = A[pos]-'0';
else lim = 9;
for(int i = 0; i <= lim; i++) {
if(i == a || i == b) continue;
if(!i && st) ret += solve(pos+1, 10, 10, 1, 1);
else ret += solve(pos+1, b, i, f|(i < lim), 0);
}
return ret;
}
int main() {
scanf("%lld %lld", &a, &b);
memset(dp, -1LL, sizeof dp);
sprintf(A, "%lld", b);
ans = solve();
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

numbers.cpp: In function 'int main()':
numbers.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld", &a, &b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
numbers.cpp:26:5: warning: '__builtin___sprintf_chk' may write a terminating nul past the end of the destination [-Wformat-overflow=]
 int main() {
     ^~~~
In file included from /usr/include/stdio.h:936:0,
                 from /usr/include/c++/7/cstdio:42,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:46,
                 from numbers.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:34:43: note: '__builtin___sprintf_chk' output between 2 and 21 bytes into a destination of size 20
       __bos (__s), __fmt, __va_arg_pack ());
                                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...