| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 248565 | eohomegrownapps | Palindrome-Free Numbers (BOI13_numbers) | C++14 | 1 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll dpv[20][11][11][2];
ll dp(int ind, int secondlast, int last, bool isSame){
if (ind==s.size()){
return 1;
}
if (dpv[ind][secondlast][last][isSame]!=-1){
return dpv[ind][secondlast][last][isSame];
}
int upper = isSame ? s[ind]-'0' : 9;
ll total = 0;
for (int i = 0; i<=upper; i++){
if ((i==last&&last!=10) || (i==secondlast&&secondlast!=10)){continue;}
total+=dp(ind+1,last,i,isSame&&i==(s[ind]-'0'));
}
if (secondlast!=-1){
dpv[ind][secondlast][last][isSame]=total;
}
return total;
}
void initdp(){
for (int i = 0; i<20; i++){
for (int j = 0; j<11; j++){
for (int k = 0; k<11; k++){
for (int l = 0; l<2; l++){
dpv[i][j][k][l]=-1;
}
}
}
}
}
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
ll a,b;
cin>>a>>b;
a--;
s=to_string(b);
initdp();
ll tot = dp(0,10,10,true);
if (a>=0){
s=to_string(a);
initdp();
tot-=dp(0,10,10,true);
}
cout<<tot<<'\n';
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
