이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long long a, b, ans;
long long f[20][15][15][2][2];
char A[20];
long long solve(int pos, int a, int b, int fs, int st) {
if(!A[pos]) return 1LL;
long long &ret = f[pos][a][b][fs][st];
if(~ret) return ret;
ret = 0;
int lim;
if(!fs) 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, fs | (i < lim), 0);
}
return ret;
}
int main() {
scanf("%lld %lld", &a, &b);
memset(f, -1LL, sizeof f);
sprintf(A, "%lld", b);
ans = solve(0, 10, 10, 0, 1);
if(a) {
memset(f, -1LL, sizeof f);
sprintf(A, "%lld", a-1);
ans -= solve(0, 10, 10, 0, 1);
}
printf("%lld\n", ans);
return 0;
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |