| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 855191 | ThylOne | Palindrome-Free Numbers (BOI13_numbers) | C++14 | 1 ms | 600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
string limit;
int dpTab[2][20][12][12];
int dp(bool L,int pos=0,int last1=10,int last2=10){
if(pos==limit.size())return 1;
if(dpTab[L][pos][last1][last2]!=-1)
return dpTab[L][pos][last1][last2];
int cnt=0;
int borne = (limit[pos]-'0');
if(!L)borne=9;
for(int digit=0;digit<=borne;digit++){
if(digit!=last1 && digit!=last2){
int L2 = (borne==digit);
if(L==false)L2=false;
cnt+=dp(L2,pos+1,digit,last1);
}
}
dpTab[L][pos][last1][last2] = cnt;
return dpTab[L][pos][last1][last2];
}
void setDp(ll lim){
limit = to_string(lim);
for(int b=0;b<2;b++){
for(int pos=0;pos<20;pos++){
for(int last1=0;last1<=10;last1++){
for(int last2=0;last2<=10;last2++){
dpTab[b][pos][last1][last2]=-1;
}
}
}
}
}
signed main(){
ll a,b;
cin>>a>>b;
int cnt=0;
setDp(b);
cnt+=dp(true,0,10,10);
setDp(a-1);
cnt-=dp(true,0,10,10);
cout<<cnt<<endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
