제출 #284639

#제출 시각아이디문제언어결과실행 시간메모리
284639ChrisTPalindrome-Free Numbers (BOI13_numbers)C++17
100 / 100
1 ms512 KiB
#include <bits/stdc++.h> using namespace std; const int MN = 1e3 + 5; long long dp[2][20][10][10]; //dp[<=][digit][last digit][2nd last digit] long long solve (long long x) { long long ret = 0; memset(dp,0,sizeof dp); for (int i = 0; i < min(100LL,x+1); i++) if (i < 10 || i/10 != i%10){ ++ret; dp[0][0][i/10][i%10] = 1; if (i <= x % 100) dp[1][0][i/10][i%10] = 1; } if (x<100) return ret; x /= 100; for (int i = 1; x; i++, x /= 10) { for (int take = 0; take < 10; take++) { for (int lst = 0; lst < 10; lst++) if (lst != take) { for (int bef = 0; bef < 10; bef++) if (lst != bef && bef != take) { dp[0][i][take][lst] += dp[0][i-1][lst][bef]; if (take == x%10) dp[1][i][take][lst] += dp[1][i-1][lst][bef]; else if (take < x%10) dp[1][i][take][lst] += dp[0][i-1][lst][bef]; } if (!take) continue; if (x>=10) ret += dp[0][i][take][lst]; else ret += dp[1][i][take][lst]; } } } return ret; } int main () { long long a,b; scanf ("%lld %lld",&a,&b); printf ("%lld\n",solve(b) - solve(a-1)); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

numbers.cpp: In function 'int main()':
numbers.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |  scanf ("%lld %lld",&a,&b);
      |  ~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...