CF1907E 题解

· · 题解

思路

本体核心:不能进位。

那就好做了,把每一位拆分分别计算,然后用组合数学中的插板法就行辣。

插板法不懂可以 bdfs。

代码

# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int t, n;
ll sum;
int main () {
    ios::sync_with_stdio (0);
    cin.tie (0);
    cout.tie (0);
    cin >> t;
    while (t --) {
        cin >> n;
        sum = 1;
        while (n) {
            sum *= (n % 10 + 2) * (n % 10 + 1) / 2;
            n /= 10;
        }
        cout << sum << '\n';
    }
    return 0;
}