Submission #1240977


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




typedef long long ll;
int N;
ll dp[15][15][2];
//-----------------------------------------------------------------------------------
int main() {
    cin >> N;

    string s = to_string(N);
    int n = s.length();
    dp[0][0][1] = 1;
    rep(i, 0, n) rep(j, 0, 11) rep(k, 0, 2) {
        int c = s[i] - '0';

        int ma = 10;
        if (k == 1) ma = c + 1;
        rep(jj, 0, ma) {
            if(k == 1 && jj == c) dp[i + 1][j + (jj == 1)][1] += dp[i][j][k];
            else dp[i + 1][j + (jj == 1)][0] += dp[i][j][k];
        }
    }

    ll ans = 0;
    rep(j, 0, 11) rep(k, 0, 2) ans += dp[n][j][k] * j;
    cout << ans << endl;
}

Submission Info

Submission Time
Task D - 1
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 100
Code Size 761 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 20 / 20 80 / 80
Status
AC × 3
AC × 22
AC × 43
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt
Subtask1 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Subtask2 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask2_21.txt, subtask2_22.txt, subtask2_23.txt, subtask2_24.txt, subtask2_25.txt, subtask2_26.txt, subtask2_27.txt, subtask2_28.txt, subtask2_29.txt, subtask2_30.txt, subtask2_31.txt, subtask2_32.txt, subtask2_33.txt, subtask2_34.txt, subtask2_35.txt, subtask2_36.txt, subtask2_37.txt, subtask2_38.txt, subtask2_39.txt, subtask2_40.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 1 ms 256 KB
subtask0_sample_02.txt AC 1 ms 256 KB
subtask0_sample_03.txt AC 1 ms 256 KB
subtask1_01.txt AC 1 ms 256 KB
subtask1_02.txt AC 1 ms 256 KB
subtask1_03.txt AC 1 ms 256 KB
subtask1_04.txt AC 1 ms 256 KB
subtask1_05.txt AC 1 ms 256 KB
subtask1_06.txt AC 1 ms 256 KB
subtask1_07.txt AC 1 ms 256 KB
subtask1_08.txt AC 1 ms 256 KB
subtask1_09.txt AC 1 ms 256 KB
subtask1_10.txt AC 1 ms 256 KB
subtask1_11.txt AC 1 ms 256 KB
subtask1_12.txt AC 1 ms 256 KB
subtask1_13.txt AC 1 ms 256 KB
subtask1_14.txt AC 1 ms 256 KB
subtask1_15.txt AC 1 ms 256 KB
subtask1_16.txt AC 1 ms 256 KB
subtask1_17.txt AC 1 ms 256 KB
subtask1_18.txt AC 1 ms 256 KB
subtask1_19.txt AC 1 ms 256 KB
subtask1_20.txt AC 1 ms 256 KB
subtask2_21.txt AC 1 ms 256 KB
subtask2_22.txt AC 1 ms 256 KB
subtask2_23.txt AC 1 ms 256 KB
subtask2_24.txt AC 1 ms 256 KB
subtask2_25.txt AC 1 ms 256 KB
subtask2_26.txt AC 1 ms 256 KB
subtask2_27.txt AC 1 ms 256 KB
subtask2_28.txt AC 1 ms 256 KB
subtask2_29.txt AC 1 ms 256 KB
subtask2_30.txt AC 1 ms 256 KB
subtask2_31.txt AC 1 ms 256 KB
subtask2_32.txt AC 1 ms 256 KB
subtask2_33.txt AC 1 ms 256 KB
subtask2_34.txt AC 1 ms 256 KB
subtask2_35.txt AC 1 ms 256 KB
subtask2_36.txt AC 1 ms 256 KB
subtask2_37.txt AC 1 ms 256 KB
subtask2_38.txt AC 1 ms 256 KB
subtask2_39.txt AC 1 ms 256 KB
subtask2_40.txt AC 1 ms 256 KB