답안 #166727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166727 2019-12-03T14:23:04 Z David_M Palindrome-Free Numbers (BOI13_numbers) C++14
100 / 100
3 ms 764 KB
#include <bits/stdc++.h>
#define ll long long
#define f(i,l,r) for(int i=l;i<=r;i++)
using namespace std; 
ll a[30],d[30][30][30][2],l,r,n,U;
ll A(ll x){
	memset(d,0,sizeof(d));U=0;
    string s=to_string(x);n=s.size();
	f(i,1,n)a[i]=s[i-1]-'0';
	f(j,1,a[1])f(k,0,9)if(k-j)
    		d[2][j][k][0]=(j<a[1]||k<a[2]),
			d[2][j][k][1]=(j==a[1])*(k==a[2]);
    f(i,2,n)f(j,0,9)f(k,0,9){U+=(d[i][j][k][0]+d[i][j][k][1])*(n==i);f(t,0,9)
		if(k-j&&k-t&&t-j)d[i+1][k][t][1]+=d[i][j][k][1]*(k==a[i])*(t==a[i+1]),
    	d[i+1][k][t][0]+=d[i][j][k][0]+d[i][j][k][1]*(t<a[i+1])*(k==a[i]);}
    f(i,0,n-3)U+=81<<(3*i);
	if(n<2)return x+1; return U+10;
}
main(){cin>>l>>r; cout<<A(r)-min(2*l,A(l-1));}

Compilation message

numbers.cpp: In function 'long long int A(long long int)':
numbers.cpp:17:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if(n<2)return x+1; return U+10;
  ^~
numbers.cpp:17:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if(n<2)return x+1; return U+10;
                     ^~~~~~
numbers.cpp: At global scope:
numbers.cpp:19:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){cin>>l>>r; cout<<A(r)-min(2*l,A(l-1));}
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 3 ms 760 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 3 ms 760 KB Output is correct
10 Correct 3 ms 760 KB Output is correct
11 Correct 3 ms 760 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 2 ms 760 KB Output is correct
14 Correct 2 ms 760 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 3 ms 760 KB Output is correct
17 Correct 3 ms 760 KB Output is correct
18 Correct 2 ms 760 KB Output is correct
19 Correct 2 ms 760 KB Output is correct
20 Correct 2 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 3 ms 732 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 732 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 2 ms 760 KB Output is correct
11 Correct 2 ms 760 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 3 ms 760 KB Output is correct
14 Correct 2 ms 760 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 760 KB Output is correct
17 Correct 3 ms 760 KB Output is correct
18 Correct 2 ms 748 KB Output is correct
19 Correct 3 ms 760 KB Output is correct
20 Correct 2 ms 760 KB Output is correct
21 Correct 3 ms 760 KB Output is correct
22 Correct 3 ms 760 KB Output is correct
23 Correct 2 ms 760 KB Output is correct
24 Correct 2 ms 760 KB Output is correct
25 Correct 3 ms 760 KB Output is correct
26 Correct 3 ms 760 KB Output is correct
27 Correct 3 ms 760 KB Output is correct
28 Correct 2 ms 764 KB Output is correct
29 Correct 3 ms 760 KB Output is correct
30 Correct 3 ms 760 KB Output is correct
31 Correct 3 ms 760 KB Output is correct
32 Correct 3 ms 760 KB Output is correct
33 Correct 2 ms 760 KB Output is correct
34 Correct 3 ms 760 KB Output is correct
35 Correct 3 ms 760 KB Output is correct
36 Correct 3 ms 760 KB Output is correct
37 Correct 3 ms 760 KB Output is correct
38 Correct 3 ms 760 KB Output is correct
39 Correct 3 ms 760 KB Output is correct
40 Correct 3 ms 760 KB Output is correct
41 Correct 3 ms 760 KB Output is correct
42 Correct 3 ms 760 KB Output is correct
43 Correct 2 ms 760 KB Output is correct
44 Correct 3 ms 764 KB Output is correct
45 Correct 3 ms 760 KB Output is correct