zoukankan      html  css  js  c++  java
  • test

    公式测试
    (egin{array}{l} 考虑问题sumlimits ^{n}_{i=1}sumlimits ^{m}_{j=1} [gcd(i,j)=p] ( n,mleqslant 1e7)\ \ Leftrightarrow sumlimits _{p}sum olimits ^{lfloor frac{min( m,n)}{p} floor }_{d=1} mu ( g) lfloor frac{n}{pd} floor lfloor frac{m}{pd} floor \ \ \ Leftrightarrow sum ^{min( n,m)}_{i=1} lfloor frac{n}{i} floor lfloor frac{m}{i} floor sumlimits _{p|i} mu left(frac{i}{p} ight)\ \ \ 以上是推到的关键步骤,\ \ 以下是细节推导。\ \ \ ( 1) ightarrow ( 2) :firstly 对每个p分别计算其对答案贡献:\ \ ( 1) Leftrightarrow sumlimits _{p}sumlimits ^{lfloor frac{n}{p} floor }_{i=1}sumlimits ^{lfloor frac{m}{p} floor }_{j=1} [gcd(i,j)=1] \ \ \ secondly 为了得到( 2) ,较简单的方法是使用mobius inv的引理\ \ mu *I=e \ \ ( *是迪利克雷卷积 I( n) =n , e( n) =[ n=1] )\ \ 即sum _{d|n} mu ( d) =[ n=1]\ \ \ ( ( 6) 的证明:将n分解,n=p_{1}^{a_{1}} p_{2}^{a_{2}} ...p_{k}^{a_{k}} ,\ 所有mu 不为0,且有i个质因子的数的贡献可以表示为C( k,i) imes ( -1)^{i} ,\ 而forall n >1:sum ^{k}_{i=1} C( k,i) imes ( -1)^{i} =0 )\ \ herefore sum _{d|gcd( i,j)} mu ( d) =[ gcd( i,j) =1]\ \ herefore ( 4) Leftrightarrow sumlimits _{p}sumlimits ^{lfloor frac{n}{p} floor }_{i=1}sumlimits ^{lfloor frac{m}{p} floor }_{j=1}sum _{d|gcd( i,j)} mu ( d)\ \ Thirdly 我们比较( 2) 和( 7) 发现sumlimits ^{lfloor frac{n}{p} floor }_{i=1}sumlimits ^{lfloor frac{m}{p} floor }_{j=1}sum _{d|gcd( i,j)} 变成了sum olimits ^{lfloor frac{min( m,n)}{p} floor }_{d=1} lfloor frac{n}{pd} floor lfloor frac{m}{pd} floor \ \ 可以这么理解,我们枚举d,计算mu ( d) 的个数,\ \ left( d的取值范围是1sim lfloor frac{min( m,n)}{p} floor ight)\ \ ecause d|gcd( i,j) herefore i,j是d的倍数时才对结果有贡献,\ \ herefore mu ( d) 有lfloor frac{n}{pd} floor lfloor frac{m}{pd} floor 个。\ \ \ \ herefore sumlimits ^{n}_{i=1}sumlimits ^{m}_{j=1} [gcd(i,j)=p]Leftrightarrow sumlimits _{p}sumlimits ^{lfloor frac{n}{p} floor }_{i=1}sumlimits ^{lfloor frac{m}{p} floor }_{j=1}sum _{d|gcd( i,j)} mu ( d) Leftrightarrow sumlimits _{p}sum olimits ^{lfloor frac{min( m,n)}{p} floor }_{d=1} mu ( g) lfloor frac{n}{pd} floor lfloor frac{m}{pd} floor \ \ \ \ \ \ \ end{array})

    [a_i /neq i ]

    [frac{a}{b} +sqrt[3]{a+b} +int ^{a}_{b} dx+overbrace{a-b}^{n+1} +wideparen{ABC} +widehat{ABC} +Uparrow H_{2} 0Uparrow ]

    ideone 测试:

    公式测试:

    [sum_{i=1}^n frac{1}{i^2} quad and quad prod_{i=1}^n frac{1}{i^2} quad and quad igcup_{i=1}^{2} R ]

    代码段测试

    #include <bits/stdc++.h>
    using namespace std;
    
    bool isPalindrome(const string& s) {
        for(int i = 0; i < s.length(); ++i) {
            if (s[i] != s[s.length() - i - 1]) 
                return false;
        }
        return true;
    }
    
    bool solve1(string s) {
        string t = s;
        for(int i = 0; i < s.length(); ++i) {
            t = t.back() + t;
            t.pop_back();
            if (s != t && isPalindrome(t)) {
                return true;
            }
        }
        return false;
    }
    
    bool anyAnswer(const string& s) {
        int nt = 0;
        for(int i = 0; i < s.length(); ++i) {
            nt += s[i] != s[0];
        }
        return nt > 1;
    }
    
    int32_t main() {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr), cout.tie(nullptr);
    
        string s;
        cin >> s;
        if (anyAnswer(s)) {
            cout << (solve1(s) ? 1 : 2) << endl;
        } else {
            cout << "Impossible" << endl;
        }
    
        return 0;
    }
    
    
    成功的路并不拥挤,因为大部分人都在颓(笑)
  • 相关阅读:
    【QT】读取目录文件,双击显示文件内容
    【QT】简易计算器实现
    【QT】使用代码方式实现简单的界面布局
    【QT】event事件使用鼠标位置
    【ffmpeg】FFMPEG常用命令
    【QT】简单文本编辑器,open,save功能
    Nginx--try_files尝试读取文件
    深浅拷贝
    CNN卷积神经网络学习笔记
    深度学习基础学习-第二章-感知器
  • 原文地址:https://www.cnblogs.com/SuuT/p/10432785.html
Copyright © 2011-2022 走看看