QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#719502#5581. Champernowne Countnickbelov#AC ✓3ms3716kbC++202.4kb2024-11-07 02:17:502024-11-07 02:17:51

Judging History

你现在查看的是最新测评结果

  • [2024-11-07 02:17:51]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3716kb
  • [2024-11-07 02:17:50]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
ostream_iterator<T> oit(const string &s = " "){ return ostream_iterator<T>(cout,s.c_str()); }
inline auto rep(int l, int r) { return views::iota(min(l, r), r); }
inline auto rep(int n) { return rep(0, n); }
inline auto rep1(int l, int r) { return rep(l, r + 1); }
inline auto rep1(int n) { return rep(1, n + 1); }
inline auto per(int l, int r) { return rep(l, r) | views::reverse; }
inline auto per(int n) { return per(0, n); }
inline auto per1(int l, int r) { return per(l, r + 1); }
inline auto per1(int n) { return per(1, n + 1); }
#define A(a) begin(a),end(a)
inline auto len = ranges::ssize;

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template<typename T, typename U> using pb_map = gp_hash_table<T, U, chash>;
template<typename T> using pb_set = gp_hash_table<T, null_type, chash>;
#define K first
#define V second

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vii = vector<vector<int>>;
typedef vector<ll> vll;
using pll = pair<ll,ll>;
using pii = pair<int,int>;

constexpr ll NN = 2e5, L = 20;

ll M;
ll f1[NN], f2[NN];
ll inv(ll a, ll b=M) { return 1 < a ? b - inv(b % a, a) * b / a : 1; } // inv a mod b
ll choose(ll n, ll k) { return f1[n] * f2[k] % M * f2[n - k] % M; } // n choose k


ll powmod(ll x, ll y){
  if(y==0) return 1LL;
  ll t=powmod(x,y/2);
  if (y%2==0) return (t*t)%M;
  return (((x*t)%M)*t)%M;
}


void run()
{
    ll n,k; cin >> n >> k; M = k;
    ll ans = 0;
    ll cur = 0;
    for(ll i : rep1(n)){
        ll pw = len(to_string(i));
        ll mult = powmod(10,pw);
        cur = cur * mult % k;
        cur = (cur+i)%k;
        ans += cur==0;
    }
    cout << ans << '\n';
}

int main()
{
    //KING OF THE WORLD...... U.W.T.B
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    run();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3712kb

input:

4 2

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

100 7

output:

14

result:

ok single line: '14'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

314 159

output:

4

result:

ok single line: '4'

Test #4:

score: 0
Accepted
time: 3ms
memory: 3624kb

input:

100000 999809848

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 3ms
memory: 3640kb

input:

100000 123

output:

161

result:

ok single line: '161'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

10000 123

output:

161

result:

ok single line: '161'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

123 123

output:

3

result:

ok single line: '3'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

123 2

output:

61

result:

ok single line: '61'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

9999 2

output:

4999

result:

ok single line: '4999'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

1 1

output:

1

result:

ok single line: '1'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

1 2

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

2 1

output:

2

result:

ok single line: '2'

Test #13:

score: 0
Accepted
time: 2ms
memory: 3712kb

input:

100000 1

output:

100000

result:

ok single line: '100000'

Test #14:

score: 0
Accepted
time: 2ms
memory: 3620kb

input:

100000 5

output:

20000

result:

ok single line: '20000'

Test #15:

score: 0
Accepted
time: 3ms
memory: 3620kb

input:

100000 100000

output:

1

result:

ok single line: '1'

Test #16:

score: 0
Accepted
time: 2ms
memory: 3552kb

input:

100000 100

output:

1000

result:

ok single line: '1000'

Test #17:

score: 0
Accepted
time: 2ms
memory: 3556kb

input:

90260 999994815

output:

1

result:

ok single line: '1'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

90259 999994815

output:

0

result:

ok single line: '0'

Test #19:

score: 0
Accepted
time: 3ms
memory: 3560kb

input:

100000 999994815

output:

1

result:

ok single line: '1'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

45816 999988008

output:

1

result:

ok single line: '1'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

45815 999988008

output:

0

result:

ok single line: '0'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

100000 999988008

output:

1

result:

ok single line: '1'

Test #23:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

39570 999976697

output:

1

result:

ok single line: '1'

Test #24:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

39569 999976697

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 3ms
memory: 3644kb

input:

100000 999976697

output:

1

result:

ok single line: '1'

Test #26:

score: 0
Accepted
time: 2ms
memory: 3640kb

input:

68109 999957767

output:

1

result:

ok single line: '1'

Test #27:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

68108 999957767

output:

0

result:

ok single line: '0'

Test #28:

score: 0
Accepted
time: 3ms
memory: 3520kb

input:

100000 999957767

output:

1

result:

ok single line: '1'

Test #29:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

66912 999953376

output:

1

result:

ok single line: '1'

Test #30:

score: 0
Accepted
time: 2ms
memory: 3632kb

input:

66911 999953376

output:

0

result:

ok single line: '0'

Test #31:

score: 0
Accepted
time: 2ms
memory: 3632kb

input:

100000 999953376

output:

1

result:

ok single line: '1'

Test #32:

score: 0
Accepted
time: 2ms
memory: 3644kb

input:

58860 999952020

output:

1

result:

ok single line: '1'

Test #33:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

58859 999952020

output:

0

result:

ok single line: '0'

Test #34:

score: 0
Accepted
time: 3ms
memory: 3564kb

input:

100000 999952020

output:

1

result:

ok single line: '1'

Test #35:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

60072 999937911

output:

1

result:

ok single line: '1'

Test #36:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

60071 999937911

output:

0

result:

ok single line: '0'

Test #37:

score: 0
Accepted
time: 3ms
memory: 3648kb

input:

100000 999937911

output:

1

result:

ok single line: '1'

Test #38:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

8388 999923214

output:

1

result:

ok single line: '1'

Test #39:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

8387 999923214

output:

0

result:

ok single line: '0'

Test #40:

score: 0
Accepted
time: 3ms
memory: 3628kb

input:

100000 999923214

output:

1

result:

ok single line: '1'

Test #41:

score: 0
Accepted
time: 2ms
memory: 3716kb

input:

69200 999921880

output:

1

result:

ok single line: '1'

Test #42:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

69199 999921880

output:

0

result:

ok single line: '0'

Test #43:

score: 0
Accepted
time: 2ms
memory: 3712kb

input:

100000 999921880

output:

1

result:

ok single line: '1'

Test #44:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

16800 999916800

output:

1

result:

ok single line: '1'

Test #45:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

16799 999916800

output:

0

result:

ok single line: '0'

Test #46:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

100000 999916800

output:

1

result:

ok single line: '1'

Test #47:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

10646 999913814

output:

1

result:

ok single line: '1'

Test #48:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

10645 999913814

output:

0

result:

ok single line: '0'

Test #49:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

100000 999913814

output:

1

result:

ok single line: '1'

Test #50:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

45710 999906239

output:

1

result:

ok single line: '1'

Test #51:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

45709 999906239

output:

0

result:

ok single line: '0'

Test #52:

score: 0
Accepted
time: 3ms
memory: 3656kb

input:

100000 999906239

output:

1

result:

ok single line: '1'

Test #53:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

86731 999904081

output:

1

result:

ok single line: '1'

Test #54:

score: 0
Accepted
time: 2ms
memory: 3516kb

input:

86730 999904081

output:

0

result:

ok single line: '0'

Test #55:

score: 0
Accepted
time: 3ms
memory: 3636kb

input:

100000 999904081

output:

1

result:

ok single line: '1'

Test #56:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

12474 999902678

output:

1

result:

ok single line: '1'

Test #57:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

12473 999902678

output:

0

result:

ok single line: '0'

Test #58:

score: 0
Accepted
time: 3ms
memory: 3648kb

input:

100000 999902678

output:

1

result:

ok single line: '1'

Test #59:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

83150 999901318

output:

1

result:

ok single line: '1'

Test #60:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

83149 999901318

output:

0

result:

ok single line: '0'

Test #61:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

100000 999901318

output:

1

result:

ok single line: '1'

Test #62:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

8014 999894587

output:

1

result:

ok single line: '1'

Test #63:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

8013 999894587

output:

0

result:

ok single line: '0'

Test #64:

score: 0
Accepted
time: 2ms
memory: 3620kb

input:

100000 999894587

output:

1

result:

ok single line: '1'

Test #65:

score: 0
Accepted
time: 2ms
memory: 3520kb

input:

66936 999887673

output:

1

result:

ok single line: '1'

Test #66:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

66935 999887673

output:

0

result:

ok single line: '0'

Test #67:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

100000 999887673

output:

1

result:

ok single line: '1'

Test #68:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

41728 999887584

output:

1

result:

ok single line: '1'

Test #69:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

41727 999887584

output:

0

result:

ok single line: '0'

Test #70:

score: 0
Accepted
time: 3ms
memory: 3632kb

input:

100000 999887584

output:

1

result:

ok single line: '1'

Test #71:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

96640 999885752

output:

1

result:

ok single line: '1'

Test #72:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

96639 999885752

output:

0

result:

ok single line: '0'

Test #73:

score: 0
Accepted
time: 3ms
memory: 3556kb

input:

100000 999885752

output:

1

result:

ok single line: '1'

Test #74:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

67446 999883926

output:

1

result:

ok single line: '1'

Test #75:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

67445 999883926

output:

0

result:

ok single line: '0'

Test #76:

score: 0
Accepted
time: 3ms
memory: 3616kb

input:

100000 999883926

output:

1

result:

ok single line: '1'

Test #77:

score: 0
Accepted
time: 2ms
memory: 3716kb

input:

66652 999883316

output:

1

result:

ok single line: '1'

Test #78:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

66651 999883316

output:

0

result:

ok single line: '0'

Test #79:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

100000 999883316

output:

1

result:

ok single line: '1'

Test #80:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

83798 999871866

output:

1

result:

ok single line: '1'

Test #81:

score: 0
Accepted
time: 2ms
memory: 3692kb

input:

83797 999871866

output:

0

result:

ok single line: '0'

Test #82:

score: 0
Accepted
time: 2ms
memory: 3556kb

input:

100000 999871866

output:

1

result:

ok single line: '1'

Test #83:

score: 0
Accepted
time: 3ms
memory: 3616kb

input:

99774 999869174

output:

1

result:

ok single line: '1'

Test #84:

score: 0
Accepted
time: 3ms
memory: 3692kb

input:

99773 999869174

output:

0

result:

ok single line: '0'

Test #85:

score: 0
Accepted
time: 2ms
memory: 3556kb

input:

100000 999869174

output:

1

result:

ok single line: '1'

Test #86:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

30840 999862260

output:

1

result:

ok single line: '1'

Test #87:

score: 0
Accepted
time: 1ms
memory: 3520kb

input:

30839 999862260

output:

0

result:

ok single line: '0'

Test #88:

score: 0
Accepted
time: 2ms
memory: 3576kb

input:

100000 999862260

output:

1

result:

ok single line: '1'

Test #89:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

10746 999860119

output:

1

result:

ok single line: '1'

Test #90:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

10745 999860119

output:

0

result:

ok single line: '0'

Test #91:

score: 0
Accepted
time: 2ms
memory: 3556kb

input:

100000 999860119

output:

1

result:

ok single line: '1'

Test #92:

score: 0
Accepted
time: 2ms
memory: 3620kb

input:

64944 999843726

output:

1

result:

ok single line: '1'

Test #93:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

64943 999843726

output:

0

result:

ok single line: '0'

Test #94:

score: 0
Accepted
time: 3ms
memory: 3712kb

input:

100000 999843726

output:

1

result:

ok single line: '1'

Test #95:

score: 0
Accepted
time: 2ms
memory: 3644kb

input:

70748 999843219

output:

1

result:

ok single line: '1'

Test #96:

score: 0
Accepted
time: 2ms
memory: 3620kb

input:

70747 999843219

output:

0

result:

ok single line: '0'

Test #97:

score: 0
Accepted
time: 3ms
memory: 3624kb

input:

100000 999843219

output:

1

result:

ok single line: '1'

Test #98:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

33824 999829088

output:

1

result:

ok single line: '1'

Test #99:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

33823 999829088

output:

0

result:

ok single line: '0'

Test #100:

score: 0
Accepted
time: 3ms
memory: 3688kb

input:

100000 999829088

output:

1

result:

ok single line: '1'

Test #101:

score: 0
Accepted
time: 2ms
memory: 3688kb

input:

100000 1000000000

output:

0

result:

ok single line: '0'