2020牛客暑期多校训练营(第一场)赛后补题+定理证明

2020牛客暑期多校训练营(第一场)

赛后补题+证明自用
其余题目稍后补上

F Infinite String Comparision

联想到无限循环小数

前置知识:如何将无限循环小数化为分数

0.1111111 0.1111111 0.1111111

x = 0.1111111 x=0.1111111 x=0.1111111,则 10 x = 1.111111 10x=1.111111 10x=1.111111,可以得到 10 x − x = 9 x = 1 \large10x-x=9x=1 10xx=9x=1,则 x = 1 9 = 1 1 0 1 − 1 \large x=\frac{1}{9}=\frac{1}{10^1-1} x=91=10111

0.123123 0.123123 0.123123

x = 0.123123 x=0.123123 x=0.123123,则 1000 x = 123.123123 1000x=123.123123 1000x=123.123123(具体乘多少倍,取决于如何把小数部分作差消掉), 999 x = 123 999x=123 999x=123,最终 x = 123 999 = 123 1 0 3 − 1 x=\frac{123}{999}=\frac{123}{10^3-1} x=999123=1031123

由此我相信你一定发现了规律,最终的分式一定是 循 环 节 1 e 循 环 节 的 长 度 − 1 \frac{循环节}{1e循环节的长度-1} 1e1

所以对于此题,我们可以将字符串化为 26 26 26进制数: s 2 6 ∣ s ∣ − 1 \frac{s}{26^{|s|}-1} 26s1s,其中 ∣ s ∣ \huge |s| s为字符串的长度

s ∞ > t ∞ \large s^{\infty}>t^{\infty} s>t,则 s 2 6 ∣ s ∣ − 1 > t 2 6 ∣ t ∣ − 1 \Huge \frac{s}{26^{|s|}-1}>\frac{t}{26^{|t|}-1} 26s1s>26t1t,则有 s ∗ 2 6 ∣ t ∣ + t > t ∗ 2 6 ∣ s ∣ + s \large s*26^{|t|}+t>t*26^{|s|}+s s26t+t>t26s+s

最终结果 s t ˉ > t s ˉ \bar{st}>\bar{ts} stˉ>tsˉ,(把 s t st st t s ts ts当成数字去看,例如100和10,它们可以拼成10010和10100)

Code:

#include <bits/stdc++.h>
using namespace std;
string s, t;
int main() {
    while (cin >> s >> t)
        if (s + t < t + s)
            puts("<");
        else if (s + t > t + s)
            puts(">");
        else
            puts("=");
    return 0;
}

参考资料:https://baike.baidu.com/item/%E6%97%A0%E9%99%90%E5%BE%AA%E7%8E%AF%E5%B0%8F%E6%95%B0%E5%8C%96%E5%88%86%E6%95%B0/8057860#3

https://blog.csdn.net/BeNoble_/article/details/107308782

拓展资料:

Periodicity Lemma:两个串 s , t s,t s,t,若 s ∞ s^{\infty} s t ∞ t^{\infty} t的前 ∣ s ∣ + ∣ t ∣ − g c d ( ∣ s ∣ , ∣ t ∣ ) |s|+|t|-gcd(|s|,|t|) s+tgcd(s,t)位都相同,则 s ∞ = = t ∞ s^{\infty}==t^{\infty} s==t

J Easy Integration

考察贝塔函数的运用,参考资料:https://baike.baidu.com/item/%E8%B4%9D%E5%A1%94%E5%87%BD%E6%95%B0/4643050?fr=aladdin

∫ 0 1 ( x − x 2 ) n d x = n ! 2 ( 2 n + 1 ) ! \large \int_{0}^{1} (x-x^2)^ndx=\frac{{n!}^2}{(2n+1)!} 01(xx2)ndx=(2n+1)!n!2

证明(分部积分法):

∫ 0 1 [ x ( 1 − x ) ] n d x = ∫ 0 1 x n ( 1 − x ) n d x = ∫ 0 1 ( 1 − x ) n n + 1 d x n + 1 \large \int_{0}^{1} [x(1-x)]^ndx=\int_{0}^{1} x^n(1-x)^ndx=\int_{0}^{1}\frac{(1-x)^n}{n+1}dx^{n+1} 01[x(1x)]ndx=01xn(1x)ndx=01n+1(1x)ndxn+1

= ( 1 − x ) n ( n + 1 ) x n + 1 ∣ 0 1 − ∫ 0 1 x n + 1 n + 1 d ( 1 − x ) n \large =\frac{(1-x)^n}{(n+1)}x^{n+1}|_0^1-\int_{0}^{1}\frac{x^{n+1}}{n+1}d(1-x)^n =(n+1)(1x)nxn+10101n+1xn+1d(1x)n

= ∫ 0 1 n x n + 1 ( 1 − x ) n − 1 n + 1 d x = n n + 1 ∫ 0 1 x n + 1 ( 1 − x ) n − 1 d x \large =\int_{0}^{1}\frac{nx^{n+1}(1-x)^{n-1}}{n+1}dx =\frac{n}{n+1}\int_{0}^{1}x^{n+1}(1-x)^{n-1}dx =01n+1nxn+1(1x)n1dx=n+1n01xn+1(1x)n1dx

同理可得:

∫ 0 1 x n + 1 ( 1 − x ) n − 1 d x = n − 1 n + 2 ∫ 0 1 x n + 2 ( 1 − x ) n − 2 d x \large \int_{0}^{1}x^{n+1}(1-x)^{n-1}dx=\frac{n-1}{n+2}\int_{0}^{1}x^{n+2}(1-x)^{n-2}dx 01xn+1(1x)n1dx=n+2n101xn+2(1x)n2dx

原 式 = n ( n − 1 ) ( n − 2 ) . . . 1 ( n + 1 ) ( n + 2 ) . . . 2 n ∫ 0 1 x 2 n d x = ( n ! ) 2 ( 2 n + 1 ) ! \large 原式=\frac{n(n-1)(n-2)...1}{(n+1)(n+2)...2n}\int_{0}^{1}x^{2n}dx =\frac{(n!)^2}{(2n+1)!} =(n+1)(n+2)...2nn(n1)(n2)...101x2ndx=(2n+1)!(n!)2

解决了定积分的问题,接下来谈一谈如何解决分数取模问题

参考资料:费马小定理https://baike.baidu.com/item/%E8%B4%B9%E9%A9%AC%E5%B0%8F%E5%AE%9A%E7%90%86

b / a m o d p = b ∗ a p − 2 m o d p \large b/a mod p=b*a^{p-2}modp b/amodp=bap2modp

Code:

#include<bits/stdc++.h>
#define int long long
typedef long long ll;
#define js ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int a[1000005];
const int p=998244353;
ll qpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%p;
        b=b>>1;
        a=a*a%p;
    }
    return res;
}
signed main(){
    js;
    a[1]=1;
    for(int i=2;i<=2000000;i++){
        a[i]=(a[i-1]*(ll)i)%p;
    }
    int n;
    while(cin>>n){
        ll q1=a[n]*a[n]%p;
        ll q2=a[2*n+1];
        ll ans=q1*qpow(q2,p-2)%p;
        cout<<ans<<endl;
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值