QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#691064#7658. German Conference for Public CountingVanLam#AC ✓1ms3716kbC++142.2kb2024-10-31 09:38:442024-10-31 09:38:45

Judging History

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

  • [2024-10-31 09:38:45]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3716kb
  • [2024-10-31 09:38:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define pii pair<int, int>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define mii map<int, int>
#define mib map<int, bool>
#define mil map<int, ll>
#define mli map<ll, int>
#define si set<int>
#define vvi vector<vi>
#define vvl vector<vl>
#define vvb vector<vb>
#define vpi vector<pii>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sub(x, l, r) (x).begin() + l, (x).begin() + r
#define rsub(x, l, r) (x).rbegin() + l, (x).rbegin() + r
#define FOR(i, a, b) for (int i = a, _b = b; i <= _b; i++)
#define FORD(i, a, b) for (int i = a, _b = b; i >= _b; i--)

#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yn yes else no
#define ny no else yes

#define int ll

#ifdef VanLam
#include <debug.h>
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1205
#endif

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int maxN = 1e6 + 5;

int calc(int n, int digit)
{
    int tmp = 0;
    int res = 0;
    while (n >= tmp * 10 + digit)
    {
        res++;
        tmp = tmp * 10 + digit;
    }

    return res;
}

int LOG10(int n)
{
    int res = 0;
    while (n)
    {
        res++;
        n /= 10;
    }
    return res;
}

void solve()
{
    int n;
    cin >> n;
    int res = LOG10(n) - 1;
    if (!res)
        res = 1;
    debug(res);
    FOR(digit, 1, 9)
    {
        res += calc(n, digit);
        debug(digit, res);
    }

    cout << res;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    int t = 1;
    // cin >> t;
    int testcase = 1;
    while (t--)
    {
        cerr << "------ CASE: " << testcase++ << " ------\n";
        solve();
        cerr << "-------- END --------\n";
    }
    return 0;
}

詳細信息

Test #1:

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

input:

5

output:

6

result:

ok single line: '6'

Test #2:

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

input:

20

output:

11

result:

ok single line: '11'

Test #3:

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

input:

44

output:

14

result:

ok single line: '14'

Test #4:

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

input:

271828182

output:

82

result:

ok single line: '82'

Test #5:

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

input:

314159265

output:

82

result:

ok single line: '82'

Test #6:

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

input:

1

output:

2

result:

ok single line: '2'

Test #7:

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

input:

2

output:

3

result:

ok single line: '3'

Test #8:

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

input:

3

output:

4

result:

ok single line: '4'

Test #9:

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

input:

4

output:

5

result:

ok single line: '5'

Test #10:

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

input:

6

output:

7

result:

ok single line: '7'

Test #11:

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

input:

7

output:

8

result:

ok single line: '8'

Test #12:

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

input:

8

output:

9

result:

ok single line: '9'

Test #13:

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

input:

9

output:

10

result:

ok single line: '10'

Test #14:

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

input:

10

output:

10

result:

ok single line: '10'

Test #15:

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

input:

11

output:

11

result:

ok single line: '11'

Test #16:

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

input:

12

output:

11

result:

ok single line: '11'

Test #17:

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

input:

13

output:

11

result:

ok single line: '11'

Test #18:

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

input:

14

output:

11

result:

ok single line: '11'

Test #19:

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

input:

15

output:

11

result:

ok single line: '11'

Test #20:

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

input:

16

output:

11

result:

ok single line: '11'

Test #21:

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

input:

17

output:

11

result:

ok single line: '11'

Test #22:

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

input:

18

output:

11

result:

ok single line: '11'

Test #23:

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

input:

19

output:

11

result:

ok single line: '11'

Test #24:

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

input:

21

output:

11

result:

ok single line: '11'

Test #25:

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

input:

22

output:

12

result:

ok single line: '12'

Test #26:

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

input:

23

output:

12

result:

ok single line: '12'

Test #27:

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

input:

24

output:

12

result:

ok single line: '12'

Test #28:

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

input:

25

output:

12

result:

ok single line: '12'

Test #29:

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

input:

999999998

output:

88

result:

ok single line: '88'

Test #30:

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

input:

999999999

output:

89

result:

ok single line: '89'

Test #31:

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

input:

1000000000

output:

90

result:

ok single line: '90'

Test #32:

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

input:

291304289

output:

82

result:

ok single line: '82'

Test #33:

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

input:

73449290

output:

76

result:

ok single line: '76'

Test #34:

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

input:

3158503

output:

62

result:

ok single line: '62'

Test #35:

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

input:

307868725

output:

82

result:

ok single line: '82'

Test #36:

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

input:

59620920

output:

75

result:

ok single line: '75'

Test #37:

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

input:

266509490

output:

82

result:

ok single line: '82'

Test #38:

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

input:

457691930

output:

84

result:

ok single line: '84'

Test #39:

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

input:

320759563

output:

82

result:

ok single line: '82'

Test #40:

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

input:

863610963

output:

87

result:

ok single line: '87'

Test #41:

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

input:

393478602

output:

83

result:

ok single line: '83'

Test #42:

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

input:

432051206

output:

83

result:

ok single line: '83'

Test #43:

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

input:

508538239

output:

84

result:

ok single line: '84'

Test #44:

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

input:

330284500

output:

82

result:

ok single line: '82'

Test #45:

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

input:

539687131

output:

84

result:

ok single line: '84'

Test #46:

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

input:

216019046

output:

81

result:

ok single line: '81'

Test #47:

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

input:

895505788

output:

88

result:

ok single line: '88'

Test #48:

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

input:

283704301

output:

82

result:

ok single line: '82'

Test #49:

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

input:

160177746

output:

81

result:

ok single line: '81'

Test #50:

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

input:

835665161

output:

87

result:

ok single line: '87'

Test #51:

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

input:

818890757

output:

87

result:

ok single line: '87'

Test #52:

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

input:

888888887

output:

87

result:

ok single line: '87'

Test #53:

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

input:

888888888

output:

88

result:

ok single line: '88'

Test #54:

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

input:

888888889

output:

88

result:

ok single line: '88'

Test #55:

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

input:

55555556

output:

75

result:

ok single line: '75'

Test #56:

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

input:

444444

output:

54

result:

ok single line: '54'

Test #57:

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

input:

999

output:

29

result:

ok single line: '29'

Test #58:

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

input:

100001

output:

50

result:

ok single line: '50'

Test #59:

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

input:

333333333

output:

83

result:

ok single line: '83'

Test #60:

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

input:

22222221

output:

71

result:

ok single line: '71'

Test #61:

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

input:

111111110

output:

80

result:

ok single line: '80'

Test #62:

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

input:

6666665

output:

65

result:

ok single line: '65'