• 2020 Multi-University Training Contest 1(待补


    2020 Multi-University Training Contest 1

    1004 Distinct Sub-palindromes

    • __思路:思维题 (n<4)时,(ans=26^n)(nge4)时,(ans=26*25*24) __
    • AC代码

    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    const ll mod = 998244353;
    
    int t;
    ll n;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> t;
        while (t -- ){
            cin >> n;
            if (n == 1)
                cout << 26 << "
    ";
            else if (n == 2)
                cout << 26 * 25 + 26 * 1 << "
    ";
            else if (n == 3)
                cout << 26 * 25 * 24 + 26 * 1 * 25 * 3 + 26 << "
    ";
            else
                cout << 26 * 25 * 24 << "
    ";
        }
        return 0;
    }
    

    1005 Fibonacci Sum

    • 思路:比赛时被疯狂卡常 卡到自闭(太菜了

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    #include <assert.h>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    inline ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    inline ll pow_mod(int a, int b, int p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = 1ll * res * a % p;
            a = 1ll * a * a % p;
            b >>= 1;
        }
        return res;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    const int mod = 1e9 + 9;
    const int K = 2e5 + 10;
    const int l = 691504013;
    const int r = 308495997;
    const int s = 276601605;
    
    int t, k, ans, L_, R_;
    int L[K], R[K], fac[K], inv[K];
    ll n, c;
    
    inline int C(int n, int m){
        return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
    }
    
    inline void init(){
        fac[0] = 1, inv[0] = 1;
        for (int i = 1; i < K; i ++ ){
            fac[i] = 1ll * fac[i - 1] * i % mod;
            inv[i] = pow_mod(fac[i], mod - 2, mod);
        }
    }
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        init();
        cin >> t;
        while (t -- ){
            ans = 0, L[0] = R[0] = 1;
            cin >> n >> c >> k;
            L_ = pow_mod(l, c % (mod - 1), mod), R_ = pow_mod(r, c % (mod - 1), mod);
            for (int i = 1; i <= k; i ++ ){
                L[i] = 1ll * L[i - 1] * L_ % mod;
                R[i] = 1ll * R[i - 1] * R_ % mod;
            }
            for (int r = 0; r <= k; r ++ ){
                int tmp = 1ll * L[k - r] * R[r] % mod;
                int res;
                if (tmp == 1)
                    res = n % mod;
                else
                    res = 1ll * tmp * (pow_mod(tmp, n % (mod - 1), mod) - 1) % mod * pow_mod(tmp - 1, mod - 2, mod) % mod;
                res = 1ll * res * C(k, r) % mod;
                if (r & 1)
                    ans -= res;
                else
                    ans += res;
                ans %= mod;
            }
            ans = (1ll * ans * pow_mod(s, k, mod)) % mod;
            ans = (ans % mod + mod) % mod;
            cout << ans << "
    ";
        }
        return 0;
    }
    

    1009 Leading Robots

    • 思路:根据加速度与位移的公式(x = p + frac{1}{2}at^2),建立(x-t^2)二维直角坐标系,直线去重后,(ans=)凸包大小

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    typedef pair<ll, ll> pll;
    const int N = 5e4 + 10;
    
    int t, n, tot, top, ans;
    int st[N];
    bool flag1[N], flag2[N];
    pll a[N], b[N];
    
    inline double operator *(pll p1, pll p2){
        return 1.0 * (p2.second - p1.second) / (p1.first - p2.first);
    }
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> t;
        while (t -- ){
            tot = 0, top = 0, ans = 0;
            memset(flag1, false, sizeof(flag1));
            memset(flag2, false, sizeof(flag2));
            cin >> n;
            for (int i = 1; i <= n; i ++ ){
                cin >> a[i].second >> a[i].first;
                a[i].second *= 2;
            }
            sort(a + 1, a + n + 1);
            for (int i = 1, j = 1; j <= n;){
                while (j < n && a[j + 1] == a[i])
                    j ++ ;
                b[ ++ tot ] = a[i];
                if (j != i)
                    flag1[tot] = true;
                j ++ ;
                i = j;
            }
            for (int i = 1, j = 1; j <= tot;){
                while (j < tot && b[i].first == b[j + 1].first)
                    j ++ ;
                i = j;
                while (top && b[st[top]].second <= b[i].second)
                    top -- ;
                while (top > 1 && b[st[top]] * b[st[top - 1]] * b[i].first + b[i].second >= b[st[top]] * b[st[top - 1]] * b[st[top]].first 
                + b[st[top]].second)
                    top -- ;
                st[ ++ top ] = i;
                j ++ ;
                i = j;
            }
            for (int i = 1; i <= top; i ++ )
                flag2[st[i]] = true;
            for (int i = 1; i <= tot; i ++ )
                if (!flag1[i] && flag2[i])
                    ans ++ ;
            cout << ans << "
    ";
        }
        return 0;
    }
    

    1011 Minimum Index

    • 思路:Lyndon分解 Duval算法

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    const int N = 1e6 + 10;
    const int mod = 1e9 + 7;
    
    int t, len, ans;
    int res[N];
    char s[N];
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        scanf("%d", &t);
        while (t -- ){
            ans = 0;
            res[1] = 1;
            scanf("%s", s + 1);
            len = strlen(s + 1);
            int i = 1;
            while (i <= len){
                int j = i + 1, k = i;
                while (j <= len && s[k] <= s[j]){
                    if (s[k] < s[j]){
                        res[j] = i;
                        k = i;
                    }
                    else{
                        res[j] = res[k] + j - k;
                        k ++ ;
                    }
                    j ++ ;
                }
                res[j] = j;
                while (i <= k)
                    i += j - k;
            }
            for (int i = len; i >= 1; i -- )
                ans = (1ll * ans * 1112 % mod + res[i]) % mod;
            cout << ans << "
    ";
        }
        return 0;
    }
    
  • 相关阅读:
    用友U8存货分类通过DataTable生成EasyUI Tree JSON
    脚本加密与解密
    CKFinker 2.5.0.1 去demo标示
    C#压缩图片时保留原始的Exif信息
    Newtonsoft.Json转换强类型DataTable错误:Self referencing loop detected with type ......
    Access无法启动应用程序,工作组信息文件丢失,或是已被其他用户已独占方式打开
    C#获取邮件客户端保存的邮箱密码
    网站ASHX不执行故障
    水晶报表打印时出现:出现通信错误 将停止打印
    UILabel居上对齐居下对齐类别扩展
  • 原文地址:https://www.cnblogs.com/Misuchii/p/13378526.html
Copyright © 2020-2023  润新知