# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
502678 | NintsiChkhaidze | Palindrome-Free Numbers (BOI13_numbers) | C++14 | 2 ms | 1168 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define s second
#define f first
#define ll long long
#define int ll
using namespace std;
string str;
int dp[20][20][55][5];
int get(int last2 = 11,int last = 10,int pos = 0,int sm = 0){
if (pos >= str.size()) return dp[last2][last][pos][sm] = 1;
if (dp[last2][last][pos][sm] != -1)
return dp[last2][last][pos][sm];
int l = 9,sum=0;
if (!sm) l = str[pos] - '0';
for (int i=0;i<=l;i++){
if (i == last || i == last2) continue;
int sm2 = sm;
if (!sm2 && i < l) sm2 = 1;
sum += get(last,i,pos + 1,sm2);
}
return dp[last2][last][pos][sm] = sum;
}
int G(int x){
if (x <= 0) return 0;
memset(dp, -1, sizeof(dp));
str = "";
while(x){
str+=(x%10)+'0';
x/=10;
}
reverse(str.begin(),str.end());
return get();
}
signed main (){
ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
ll a,b;
cin>>a>>b;
cout<<G(b) - G(a - 1)<<"\n";
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |