CSES - Putka Open 2015 – 3/6 - Results
Submission details
Task:Onnenluku
Sender:
Submission time:2015-09-12 19:24:34 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.06 s1details
#20.05 s1details
#30.06 s1details
#40.05 s1details
#50.05 s1details
#60.05 s2details
#70.06 s2details
#80.05 s2details
#90.05 s2details
#100.06 s2details
#110.05 s3details
#120.05 s3details
#130.05 s3details
#140.05 s3details
#150.04 s3details

Code

#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;

ll pot(ll x){
    return (1ll<<x);
}

ll luck(string s, char a, char b){
    ll r=0;
    if (s.size()>1) r+=pot((int)s.size()-1);
    int h=0;
    for (int i=0;i<(int)s.size();i++){
        h=0;
        if (s[i]>b){
            r+=pot((int)s.size()-i);
        }
        else if(b>s[i]&&s[i]>a){
            r+=pot((int)s.size()-1-i);
        }
        else if (s[i]==b){
            r+=pot((int)s.size()-1-i);
            h=1;
        }
        else if(s[i]==a){
            h=1;
        }
        if (!h) break;
        if (h==1&&i==(int)s.size()-1){
            r++;
        }
    }
    return r;
}

ll luck2(string s, char a){
    ll r=0;
    r+=(ll)s.size()-1;
    for (int i=0;i<(int)s.size();i++){
        if (s[i]<a) return r;
        if (s[i]>a) return r+1;
    }
    return r+1;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string a,b;
    cin>>a>>b;
    ll v=0;
    for (char ac='1';ac<='9';ac++){
        for (char bc=ac+1;bc<='9';bc++){
            v+=luck(b, ac, bc);
            v-=luck(a, ac, bc);
        }
    }

    for (int c='1';c<='9';c++){
        v-=luck2(b, c)*8;
        v+=luck2(a, c)*8;
    }
    map<char, int> lol;
    for (int i=0;i<(int)a.size();i++){
        lol[a[i]]=1;
    }
    if (lol.size()==2){
        v++;
    }
    cout<<v<<endl;
}

Test details

Test 1

Group: 1

Verdict:

input
2157 93337

correct output
1421

user output
1133

Test 2

Group: 1

Verdict:

input
4875 95124

correct output
1278

user output
990

Test 3

Group: 1

Verdict:

input
5577 96352

correct output
1245

user output
957

Test 4

Group: 1

Verdict:

input
8362 92950

correct output
1076

user output
788

Test 5

Group: 1

Verdict:

input
5658 96660

correct output
1238

user output
950

Test 6

Group: 2

Verdict:

input
51312303535233 994542403556353

correct output
1453976

user output
1159064

Test 7

Group: 2

Verdict:

input
25636920452341 934558290712847

correct output
1544072

user output
1249160

Test 8

Group: 2

Verdict:

input
7917952071965 985207415843573

correct output
1763176

user output
1320808

Test 9

Group: 2

Verdict:

input
48991581181227 907034837225965

correct output
1380248

user output
1085336

Test 10

Group: 2

Verdict:

input
47968703305149 924246001328437

correct output
1396632

user output
1101720

Test 11

Group: 3

Verdict:

input
292953755324413237753216241025...

correct output
53286731528535944

user output
43153632366952328

Test 12

Group: 3

Verdict:

input
373990979330820426927419348165...

correct output
51580289482227600

user output
41447190320643984

Test 13

Group: 3

Verdict:

input
701417326319476057561825658890...

correct output
42924933948374952

user output
32791834786791336

Test 14

Group: 3

Verdict:

input
177202883511434557056457305647...

correct output
54500592365600640

user output
44367493204017024

Test 15

Group: 3

Verdict:

input
977665117437419620152569155919...

correct output
38562071809359800

user output
28428972647776184