CSES - Putka Open 2015 – 3/6 - Results
Submission details
Task:Onnenluku
Sender:
Submission time:2015-09-12 21:34:03 +0300
Language:C++
Status:READY
Result:19
Feedback
groupverdictscore
#1ACCEPTED19
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.06 s1details
#2ACCEPTED0.06 s1details
#3ACCEPTED0.06 s1details
#4ACCEPTED0.06 s1details
#5ACCEPTED0.07 s1details
#6--2details
#7--2details
#8--2details
#9--2details
#10--2details
#110.05 s3details
#120.05 s3details
#130.05 s3details
#140.06 s3details
#150.05 s3details

Code

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>

#define uint unsigned int
#define INF 999999999
#define ll long long
#define M 1000000007
#define E 0.0000001
#define N 131072

using namespace std;

/**
332617
=> 333222
332217
=> 332222
44238
=> 44242
44248
=> 44333

22362
=> 22422
22316
=> 22322
22438
=> 22442
*/

int main () {
    ll a, b;
    cin>>a>>b;
    ll ans = 0;
    for (int i = a; i <= b; i++) {
        int t = i;
        set<char> c;
        while (t) {
            c.insert((char)((t % 10) + '0'));
            t /= 10;
        }
        if (c.size() == 2 && c.count('0') == 0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

/*int main () { // WIP-koodi, joka ei toimi viel.
    string a, b;
    cin>>a>>b;

    long long ans = 0;
    long long multi = 2;

    for (int i = a.length(); i <= b.length(); i++) {
        int x = multi - 1;
        ans += x * 9 * 8;

        if (i == a.length()) {
            int f = (int)(a[0] - '0');
            ans -= x * (f - 1) * 8;
            string c = a;
            int s = -1;
            int si = -1;
            int sf = -1;
            bool d = false;
            for (int z = 1; z < i; z++) {
                int q = (int)(a[z] - '0');
                if (s == -1) {
                    if (q != f) {
                        s = q;
                        si = z;
                        sf = z;
                    }
                } else if (!d) {
                    if (q == s) si = z;
                    if (q != s && q != f) {
                        if (s < f) {
                            if (q < s) c[z] = (char)(s + '0');
                            else if (q < f) {
                                c[z] = (char)(f + '0');
                            } else if (s + 1 == f) {
                                c[si] = (char)(f + '0');
                                for (int tx = si; tx < z; tx++) c[tx + 1] = (char)(s + '0');
                            } else {
                                s++;
                                for (int tx = sf; tx <= z; tx++) c[tx] = (char)(s + '0');
                            }
                        } else {
                            if (q < f) c[z] = (char)(f + '0');
                            else if (q < s) {
                                c[z] = (char)(s + '0');
                            } else if ((c[z - 1] - '0') == s) {
                                s++;
                                if (s == f) s++;
                                if (s == 10) s = 0;
                                c[sf] = (char)(s + '0');
                                for (int tx = sf; tx < z; tx++) c[tx + 1] = (char)(f + '0');
                            } else {
                                c[z] = (char)(f + '0');
                                c[z - 1] = (char)(s + '0');
                            }
                        }
                        d = true;
                    }
                } else {
                    c[z] = (char)(min(s, f) + '0');
                }
            }
            if (s == -1) {
                ans -= x * 8;
            } else {
                int pe = 0;
                if (f < s) {
                    for (int i = 1; i < c.length(); i++) {
                        if (c[c.length() - i] == (s + '0')) pe += 1<<(i - 1);
                    }
                    ans -= (s - 2) * x;
                }
                else {
                    pe = (1<<(c.length() - 1)) - 1;
                    for (int i = 1; i < c.length(); i++) {
                        if (c[i] == (s + '0')) pe -= 1<<(i - 1);
                    }
                    ans -= (s - 2) * x;
                }
                cout<<pe<<" "<<ans<<endl;
                ans -= pe - 1;
                cout<<ans<<endl;
            }
            cout<<c<<endl;
        }
        if (i == b.length()) {

        }

        multi *= 2;
    }

    cout<<ans<<endl;

    return 0;
}*/
/**
222223
1*****
21****
**/
/**
((2^(len-1)) - 1) * 72
72 = 1 * 3 * 3 * 2 * 2 * 2
216 = 3 * 3 * 3 * 2 * 2 * 2
504 = 7 * 3 * 3 * 2 * 2 * 2
1080 = 15 * 3 * 3 * 2 * 2 * 2
2232 = 31 * 3 * 3 * 2 * 2 * 2

permutations:
1
*/

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
2157 93337

correct output
1421

user output
1421

Test 2

Group: 1

Verdict: ACCEPTED

input
4875 95124

correct output
1278

user output
1278

Test 3

Group: 1

Verdict: ACCEPTED

input
5577 96352

correct output
1245

user output
1245

Test 4

Group: 1

Verdict: ACCEPTED

input
8362 92950

correct output
1076

user output
1076

Test 5

Group: 1

Verdict: ACCEPTED

input
5658 96660

correct output
1238

user output
1238

Test 6

Group: 2

Verdict:

input
51312303535233 994542403556353

correct output
1453976

user output
(empty)

Test 7

Group: 2

Verdict:

input
25636920452341 934558290712847

correct output
1544072

user output
(empty)

Test 8

Group: 2

Verdict:

input
7917952071965 985207415843573

correct output
1763176

user output
(empty)

Test 9

Group: 2

Verdict:

input
48991581181227 907034837225965

correct output
1380248

user output
(empty)

Test 10

Group: 2

Verdict:

input
47968703305149 924246001328437

correct output
1396632

user output
(empty)

Test 11

Group: 3

Verdict:

input
292953755324413237753216241025...

correct output
53286731528535944

user output
0

Test 12

Group: 3

Verdict:

input
373990979330820426927419348165...

correct output
51580289482227600

user output
0

Test 13

Group: 3

Verdict:

input
701417326319476057561825658890...

correct output
42924933948374952

user output
0

Test 14

Group: 3

Verdict:

input
177202883511434557056457305647...

correct output
54500592365600640

user output
0

Test 15

Group: 3

Verdict:

input
977665117437419620152569155919...

correct output
38562071809359800

user output
0