| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 342340 | jeroenodb | Palindrome-Free Numbers (BOI13_numbers) | C++14 | 1 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <bitset>
#include <cassert>
#include <algorithm>
#include <cstring>
using namespace std;
#define all(x) begin(x),end(x)
typedef long long ll;
const int mxN = 1e5+1;
ll dp[18][11][11][2];
vector<int> dig;
ll recur(int i=0, int p=10, int pp=10, bool free=false) {
if(i==dig.size()) return 1;
if(dp[i][p][pp][free]) {
return dp[i][p][pp][free]-1;
}
dp[i][p][pp][free]++;
int limit = free?9:dig[i];
for(int d=0;d<=limit;++d) {
if(d==p or d==pp) continue;
int tmp = d;
if(p==10 and d==0) {
tmp=10;
}
dp[i][p][pp][free]+=recur(i+1,tmp,p,free or d!=dig[i]);
}
return dp[i][p][pp][free]-1;
}
ll solve(ll a) {
if(a==-1) return 0;
memset(&dp[0][0][0][0], 0,sizeof(dp));
dig.clear();
while(a!=0) {
dig.push_back(a%10);
a/=10;
}
reverse(all(dig));
return recur();
}
int main() {
ll a,b; cin >> a >> b;
cout << solve(b) - solve(a-1) << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
