vscode格式化代码, 谷歌风格, 允许短if同行短块同行, tab = 4舒适风格

ctrl + ,输入format, 点开C++风格设置

在这块内容输入{ BasedOnStyle: Chromium, IndentWidth: 4, ColumnLimit: 200, AllowShortIfStatementsOnASingleLine: true, AllowShortLoopsOnASingleLine: true}

C_Cpp: Clang_format_fallback Style
用作回退的预定义样式的名称,以防使用样式 file 调用 clang-format 但找不到 .clang-format 文件。可能的值为 Visual Studio、LLVM、 Google、Chromium、Mozilla、WebKit、 Microsoft、GNU、none,或使用 {键: 值, ...} 以设置特定参数。例如,Visual Studio 样式类似于: { BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }。

这样可以获得比较舒服的代码格式

代码风格展示

#include <bits/stdc++.h>
#define all(c) c.begin(), c.end()
#define int long long
using namespace std;
using LL = long long;
const double PI = acos(-1);
static constexpr long long mod = 998244353;
int calc(string s) {
    int m = s.size();
    int memo[m + 1][2010][10];
    memset(memo, -1, sizeof(memo));
    function<int(bool, bool, int, int, int)> f = [&](bool is_limit, bool is_num, int pos, int sum, int last) -> int {
        if (pos == m) {
            if (!is_num) return 0;
            if (last <= 0) return 0;
            return (sum - last) % last == 0;
        }
        if (!is_limit && is_num && memo[pos][sum][last] != -1) {
            return memo[pos][sum][last];
        }
        int res = 0;
        if (!is_num) {
            // 可以跳过当前数位
            res += f(false, false, pos + 1, sum, -1);
            res %= mod;
        }
        int up = is_limit ? s[pos] - '0' : 9;
        int low = is_num ? 0 : 1;
        for (int d = low; d <= up; ++d) {
            res += f(is_limit && up == d, is_num || d != 0, pos + 1, sum + d, d);
            res %= mod;
        }
        if (!is_limit && is_num) {
            memo[pos][sum][last] = res;
        }
        return res;
    };
    return f(true, false, 0, 0, -1);
}
bool check(string L) {
    if (L.size() < 2) return false;
    int sum = 0;
    for (int i = 0; i < L.size() - 1; ++i) {
        sum += L[i] - '0';
    }
    if (L.back() == '0') return false;
    return sum % (L.back() - '0') == 0;
}
void solve() {
    string l, r;
    cin >> l >> r;
    int ans = calc(r) - calc(l) + check(l);
    ans = (ans + mod) % mod;
    cout << ans << endl;
}
signed main() {
    std::ios::sync_with_stdio(false);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值