• 2020 Multi-University Training Contest 5(待补


    2020 Multi-University Training Contest 5

    1001 Tetrahedron

    • 思路:可以根据类比平面几何的直角三角形 得到三个直角面面积和等于底面面积 然后得到式子 由于是离散型随机变量的期望 求和即可

    • 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 mod = 998244353;
    const int N = 6e6 + 10;
    
    int t, n;
    int inv[N];
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        inv[1] = 1;
        for (int i = 2; i < N; i ++ )
            inv[i] = (1ll * (mod -(mod / i)) * inv[mod % i] % mod + mod) % mod;
        for (int i = 2; i < N; i ++ )
            inv[i] = 1ll * inv[i] * inv[i] % mod;
        for (int i = 2; i < N; i ++ )
            inv[i] = (1ll * inv[i] + 1ll * inv[i - 1]) % mod;
        cin >> t;
        while (t -- ){
            cin >> n;
            cout << mult_mod(3, mult_mod(pow_mod(n, mod - 2, mod), inv[n], mod), mod) << "
    ";
        }
        return 0;
    }
    

    1003 Boring Game

    • 思路:模拟

    • 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 Pow(ll a, ll b){
        ll res = 1;
        while (b){
            if (b & 1)
                res *= a;
            a *= a;
            b >>= 1;
        }
        return res;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    const int N = 1e6 + 10;
    
    int t, n, k, m, pos, tmp;
    vector<int> vec[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 -- ){
            pos = 1;
            cin >> n >> k;
            m = 2 * n * Pow(2, k);
            for (int i = 1; i <= m; i ++ ){
                int x;
                cin >> x;
                vec[i].clear();
                vec[i].push_back(x);
            }
            while (k -- ){
                tmp = (pos + m) >> 1;
                for (int i = pos; i <= tmp; i ++ ){
                    for (int j = vec[i].size() - 1; j >= 0; j -- )
                        vec[pos + m - i].push_back(vec[i][j]);
                }
                pos = tmp + 1;
            }
            for (int i = m - 2 * n + 1; i <= m; i ++ ){
                for (int j = vec[i].size() - 1; j >= 0; j -- ){
                    if (i == m && j == 0)
                        cout << vec[i][j] << "
    ";
                    else
                        cout << vec[i][j] << " ";
                }
            }
        }
        return 0;
    }
    

    1009 Paperfolding

    • 思路:(frac{3^n}{2^{n-1}}+2^n+1)

    • 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 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;
            cout << ((1ll * pow_mod(2, n, mod) + mult_mod(1ll * 2, mult_mod(pow_mod(3, n, mod), pow_mod(pow_mod(2, n, mod), mod - 2, mod), mod), mod)) % mod + 1) % mod << "
    ";
        }
        return 0;
    }
    

    1012 Set1

    • 思路:前(lfloor frac{n}{2} floor)都为0 (ans_frac{n+1}{2}=inv(2^{frac{n}{2}})) 之后到第(n-1)个数都有(ans_i = ans_{i-1}*(frac{n}{2}+i)*inv(2*i)) (ans_n=ans_{n-1})

    • 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 mod = 998244353;
    
    int t, n;
    ll ans;
    
    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 << "1
    ";
                continue;
            }
            for (int i = 1; i <= n / 2; i ++ )
                cout << "0 ";
            ans = pow_mod(pow_mod(2, n / 2, mod), mod - 2, mod);
            cout << ans << " ";
            for (int i = 1; i < n / 2; i ++ ){
                ans = mult_mod(ans, mult_mod(n / 2 + i, pow_mod(2 * i, mod - 2, mod), mod), mod);
                cout << ans << " ";
            }
            cout << ans << "
    ";
        }
        return 0;
    }
    
  • 相关阅读:
    Support依赖库大全
    反射调用泛型
    会爬行的小乌龟
    改进版——使用了双缓冲技术
    启动运行发现窗体不能最大化,添加
    添加图层
    实现放大,缩小,漫游,复位等功能
    从上一个项目中我得到的反思
    ​Error -4075: File not found. An error occurred merging module <MODULENAME> for feature <FEATURENAME>.
    总结—angularjs项目
  • 原文地址:https://www.cnblogs.com/Misuchii/p/13461096.html
Copyright © 2020-2023  润新知