国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Educational Codeforces Round 151 (Rated for Div. 2)

這篇具有很好參考價值的文章主要介紹了Educational Codeforces Round 151 (Rated for Div. 2)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

Edu 151

A. Forbidden Integer

題意
你有[1, k]內(nèi)除了 x x x的整數(shù),每個數(shù)可以拿多次,問 ∑ = n \sum = n =n是否可行并構(gòu)造
思路
有1必能構(gòu)造,否則假如沒有1,假如有2, 3必定能構(gòu)造出大于等于2的所有數(shù),否則只有2的話只能構(gòu)造出偶數(shù)。

#include <bits/stdc++.h>
#define local
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
using ll = long long;
using db = double;
using PII = pair<int, int>;
using PLI = pair<ll, int>;

template<class T>
ostream &operator<<(ostream &io, vector<T> a) {
    io << "{"; 
    for (auto I: a)io << I << " ";
    io << "}";
    return io;
}

template<class T>
ostream &operator<<(ostream &io, set<T> a) {
    io << "{"; 
    for (auto I: a)io << I << " ";
    io << "}";
    return io;
}

template<class K, class V>
ostream &operator<<(ostream &io, map<K, V> a) {
    io << "(";
    for (auto I: a)io << "{" << I.first << ":" << I.second << "}";
    io << ")"; 
    return io;
}

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << ' ' << H;
    debug_out(T...);
}

#ifdef local
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif
#define all(x) x.begin(),x.end()


int main() {
    IOS
    int t;
    cin >> t;
    while (t--) {
        int n, k, x;
        cin >> n >> k >> x;
        if (x == 1) {
            if (k == 1) {
                cout << "NO\n";
            } else if (k == 2) {
                if (n % 2 == 0) {
                    cout << "YES\n";
                    cout << n / 2 << '\n';
                    for (int i = 1; i <= n / 2; ++i) {
                        cout << 2 << " ";
                    }
                    cout << '\n';
                } else {
                    cout << "NO\n";
                }
            } else {
                if (n % 2 == 0) {
                    cout << "YES\n";
                    cout << n / 2 << '\n';
                    for (int i = 1; i <= n / 2; ++i) {
                        cout << 2 << " ";
                    }
                    cout << '\n';
                } else {
                    if (n == 1) {
                        cout << "NO\n";
                    } else {
                        cout << "YES\n";
                        cout << 1 + (n - 3) / 2 << "\n";
                        cout << 3 << " ";
                        for (int i = 1; i <= (n - 3) / 2; ++i) {
                            cout << 2 << " ";
                        }
                        cout << '\n';
                    }
                }
            }
        } else {
            cout << "YES\n";
            cout << n << '\n';
            for (int i = 1; i <= n; ++i) {
                cout << 1 << ' ';
            }
            cout << "\n";
        }
    }
    return 0;
}

B. Come Together

題意
棋盤上兩個點同時從C出發(fā)到A, B, 都走最短路徑,問最多重疊的格子數(shù)
思路:不難發(fā)現(xiàn),x, y軸對答案的貢獻是獨立的,考慮其中一維,假如在同方向才能有貢獻,分類討論即可。

#include <bits/stdc++.h>
#define local
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
using ll = long long;
using db = double;
using PII = pair<int, int>;
using PLI = pair<ll, int>;

template<class T>
ostream &operator<<(ostream &io, vector<T> a) {
    io << "{"; 
    for (auto I: a)io << I << " ";
    io << "}";
    return io;
}

template<class T>
ostream &operator<<(ostream &io, set<T> a) {
    io << "{"; 
    for (auto I: a)io << I << " ";
    io << "}";
    return io;
}

template<class K, class V>
ostream &operator<<(ostream &io, map<K, V> a) {
    io << "(";
    for (auto I: a)io << "{" << I.first << ":" << I.second << "}";
    io << ")"; 
    return io;
}

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << ' ' << H;
    debug_out(T...);
}

#ifdef local
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif
#define all(x) x.begin(),x.end()


int main() {
    IOS
    int t;
    cin >> t;
    while (t--) {
        int xa, ya, xb, yb, xc, yc;
        cin >> xa >> ya >> xb >> yb >> xc >> yc;
        int x1 = xb - xa, x2 = xc - xa, y1 = yb - ya, y2 = yc - ya;
        int ans = 1;
        if ((ll)x1 * x2 >= 0) {
            if (abs(x1) > abs(x2)) 
                swap(x1, x2);
            ans += abs(x1);
        } 
        if ((ll)y1 * y2 >= 0) {
            if (abs(y1) > abs(y2)) 
                swap(y1, y2);
            ans += abs(y1);
        }
        cout << ans << '\n';
    }
    return 0;
}

C. Strong Password

題意
給定字符串 s s s,問是否存在長度為 m m m, 每個密碼的第 i i i位數(shù)字在 [ l i , r i ] [l_i, r_i] [li?,ri?]之間,且不為 s s s的子序列的字符串。
思路
每個密碼在 s s s中都是獨立的,顯然我們要讓它不為子序列,貪心的考慮在 i i i這個位置選擇最靠后的字母,建出子序列自動機模擬即可。

#include <bits/stdc++.h>
#define local
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
using ll = long long;
using db = double;
using PII = pair<int, int>;
using PLI = pair<ll, int>;

template<class T>
ostream &operator<<(ostream &io, vector<T> a) {
    io << "{"; 
    for (auto I: a)io << I << " ";
    io << "}";
    return io;
}

template<class T>
ostream &operator<<(ostream &io, set<T> a) {
    io << "{"; 
    for (auto I: a)io << I << " ";
    io << "}";
    return io;
}

template<class K, class V>
ostream &operator<<(ostream &io, map<K, V> a) {
    io << "(";
    for (auto I: a)io << "{" << I.first << ":" << I.second << "}";
    io << ")"; 
    return io;
}

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << ' ' << H;
    debug_out(T...);
}

#ifdef local
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif
#define all(x) x.begin(),x.end()


int main() {
    IOS
    int t;
    cin >> t;
    while (t--) {
        string s;
        cin >> s;
        int n = s.length();
        s = ' ' + s;
        int m;
        cin >> m;
        string l, r;
        cin >> l >> r;
        l = ' ' + l;
        r = ' ' + r;
        vector<vector<int>> nxt(n + 1, vector<int>(10, 0));
        for (int i = 0; i < 10; ++i)
            nxt[n][i] = n + 1;
        for (int i = n - 1; i >= 0; --i) {
            for (int j = 0; j < 10; ++j) {
                if (s[i + 1] - '0' == j) {
                    nxt[i][j] = i + 1;
                } else {
                    nxt[i][j] = nxt[i + 1][j];
                }
            }
        }
        int ps = 0;
        bool f = 0;
        for (int i = 1; i <= m; ++i) {
            int mx = 0;
            if (f)
            	break;
            for (int j = l[i]; j <= r[i]; ++j) {
                mx = max(mx, nxt[ps][j - '0']);
                if (mx >= n + 1) {
                    f = 1;
                    break;
                }
            }
            ps = mx;
        }
        if (ps >= n + 1)
            f = 1;
        cout << (f ? "YES\n" : "NO\n");
    }
    return 0;
}

D. Rating System

題意
給出長度為 n n n的序列 a {a} a, 有一個數(shù) s s s, 第 i i i次操作會使 s s s加上 a i a_i ai?, 選擇一個值 k k k, 當 s > = k s >= k s>=k的時候, s s s不會再小于 k k k, 求 n n n次操作后使得 s s s最大的整數(shù) k k k, 輸出任意一種

思路
原函數(shù)圖大體上是折線型的,不難想到答案最大的時候, k k k一定是 ∑ a i ( 下降時候取到的 s u m ) \sum a_i(下降時候取到的sum) ai?(下降時候取到的sum)。s的變化分為三個階段:到達 k k k, 經(jīng)過一些操作下降到 k k k,再也不會收到 k k k的限制??紤]枚舉第三階段的起點 i i i, 那么答案就是k + sum[n] - sum[i - 1], 維護前綴最大sum更新 k k k即可。

#include <bits/stdc++.h>
#define local
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
using ll = long long;
using db = double;
using PII = pair<int, int>;
using PLI = pair<ll, int>;

template<class T>
ostream &operator<<(ostream &io, vector<T> a) {
    io << "{"; 
    for (auto I: a)io << I << " ";
    io << "}";
    return io;
}

template<class T>
ostream &operator<<(ostream &io, set<T> a) {
    io << "{"; 
    for (auto I: a)io << I << " ";
    io << "}";
    return io;
}

template<class K, class V>
ostream &operator<<(ostream &io, map<K, V> a) {
    io << "(";
    for (auto I: a)io << "{" << I.first << ":" << I.second << "}";
    io << ")"; 
    return io;
}

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << ' ' << H;
    debug_out(T...);
}

#ifdef local
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif
#define all(x) x.begin(),x.end()


int main() {
    IOS
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        vector<int> a(n + 1, 0);
        for (int i = 1; i <= n; ++i)
            cin >> a[i];
        vector<ll> sum(n + 1, 0);
        sum[1] = a[1];
        for (int i = 2; i <= n; ++i) {
            sum[i] = sum[i - 1] + a[i];
        }
        ll mx = 0, ans = 0, ans2 = 0;
        for (int i = 1; i <= n; ++i) {
            ll now = sum[n] - sum[i - 1] + mx;
            if (now > ans) {
                ans2 = mx;
                ans = now;
            }
            mx = max(mx, sum[i]);
        }
        if (mx > ans) {
            ans2 = mx;
        }
        cout << ans2 << "\n";
    }
    return 0;
}

E. Boxes and Balls

題意
給定 n n n個盒子,其中一些盒子有球,保證不可能全滿或者全空。每次可以移動球到相鄰的空盒子,問恰好移動 k k k次的情況下球體排列狀況有多少可能性。
思路

  • 最后的排列中,球體的相對位置不會改變
  • 容易想到一個 d p dp dp, d p [ i ] [ j ] [ k ] dp[i][j][k] dp[i][j][k]表示當前枚舉到第 i i i個位置,放了 j j j個球,移動次數(shù)之和為 k k k的方案。時間復雜度是 O ( n 2 k ) O(n^2k) O(n2k)對于相對位置移動次數(shù)之和的統(tǒng)計,套路的轉(zhuǎn)化為位置間隔被經(jīng)過次數(shù)的統(tǒng)計之和。對于i后面的間隔,前面的所有存在的球都會對其有貢獻,貢獻為 ∣ s u m i ? s u m i ′ ∣ |sum_i - sum'_i| sumi??sumi?, s u m i 為移動前的 ∑ a i sum_i為移動前的\sum a_i sumi?為移動前的ai?, s u m i ′ sum'_i sumi?為移動后的。又由于題目要求每個間隔的貢獻 ∑ ∣ s u m i ? s u m i ′ ∣ ≤ k \sum |sum_i - sum'_i| \leq k sumi??sumi?k s u m i ′ ? s u m i ? 1 ′ ≤ 1 sum'_i - sum'_{i - 1} \leq 1 sumi??sumi?1?1, 考慮前面所有位置對前綴 i i i所有的間隔的貢獻,最優(yōu)情況是個等差數(shù)列,所以對于每個 i i i, ∣ s u m i ? s u m i ′ ∣ < = s q r t ( k ) |sum_i - sum'_i| <= sqrt(k) sumi??sumi?<=sqrt(k),改變 d p dp dp定義, d p [ i ] [ j ] [ k ] dp[i][j][k] dp[i][j][k]表示當前枚舉到第 i i i個盒子,新排列比原排列多 j j j個球,移動次數(shù)為 k k k的方案數(shù),轉(zhuǎn)移的時候枚舉下一位放不放即可。
#include <bits/stdc++.h>
#define local
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
using ll = long long;
using db = double;
using PII = pair<int, int>;
using PLI = pair<ll, int>;

template<class T>
ostream &operator<<(ostream &io, vector<T> a) {
    io << "{"; 
    for (auto I: a)io << I << " ";
    io << "}";
    return io;
}

template<class T>
ostream &operator<<(ostream &io, set<T> a) {
    io << "{"; 
    for (auto I: a)io << I << " ";
    io << "}";
    return io;
}

template<class K, class V>
ostream &operator<<(ostream &io, map<K, V> a) {
    io << "(";
    for (auto I: a)io << "{" << I.first << ":" << I.second << "}";
    io << ")"; 
    return io;
}

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << ' ' << H;
    debug_out(T...);
}

#ifdef local
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif
#define all(x) x.begin(),x.end()

const int maxn = 1505;
const int mod = 1e9 + 7;
int f[2][140][maxn];

void Add(int &x, int y) {
    x += y;
    if (x >= mod)
        x -= mod;
}
int a[maxn];
int main() {
    IOS
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int del = 57;
    int op = 0;
    f[op][0 + del][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = max(-del, -i); j <= min(i, del); ++j) {
            for (int v = 0; v <= k; ++v) {
                if (!f[op][j + del][v])
                    continue;
                for (auto q : {0, 1}) {
                    int nx1 = j + q - a[i + 1];
                    int nx2 = v + abs(nx1);
                    if (nx2 > k)
                        continue;
                    Add(f[op ^ 1][nx1 + del][nx2], f[op][j + del][v]);
                }
            }
        }
        for (int j = max(-del, -(i + 1)); j <= min(i + 1, del); ++j) {
            for (int v = 0; v <= k; ++v) {
                f[op][j + del][v] = 0;
            }
        }
        op ^= 1;
    }
    int ans = 0;
    for (int i = k; i >= 0; i -= 2) {
        Add(ans, f[op][0 + del][i]);
    }
    cout << ans;
    return 0;
}

F.Swimmers in the Pool

題意
游泳道 n n n個人來回游,速度 v i v_i vi?, 泳道長 l l l, 總共游 t t t時刻,問有多少個時刻至少有2個人碰到。
思路
對于 i i i j j j兩個人,相遇的時刻 t = 2 k l ∣ v i ? v j ∣ t = \frac{2kl}{|v_i - v_j|} t=vi??vj?2kl?或者 t = 2 k l v i + v j t = \frac{2kl}{v_i + v_j} t=vi?+vj?2kl?, 對于 ∣ v i ? v j ∣ |v_i - v_j| vi??vj? v i + v j v_i + v_j vi?+vj?是否存在,卷積即可?,F(xiàn)在問題變成統(tǒng)計 a = 2 k l b a = \frac{2kl} a=b2kl?, 化簡即統(tǒng)計 a = k b a = \frac{k} a=bk?, a 屬于 [ 0 , t 2 l ] a屬于[0, \frac{t}{2l}] a屬于[0,2lt?], 對于 a a a的統(tǒng)計是唯一的,考慮枚舉所有滿足條件的 b b b, 對于 g c d ( k , b ) = 1 gcd(k, b) = 1 gcd(k,b)=1的答案必定是唯一的, ∑ k = 1 t b 2 l [ g c d ( k , b ) = 1 ] = ∑ d ∣ b m u [ b ] ( t b ) / ( 2 l ) / d \sum\limits_{k = 1} ^ {{\frac{tb}{2l}}}[gcd(k, b) = 1] = \sum_{d|b} mu[b] (tb) / (2l) / d k=12ltb??[gcd(k,b)=1]=db?mu[b](tb)/(2l)/d, 那對于不互質(zhì)的數(shù)要如何計算呢,不難發(fā)現(xiàn)假如不互質(zhì),設 g c d ( k , b ) gcd(k, b) gcd(k,b) = d, 其必定在 b b b的某個約數(shù) b d \fracn5n3t3z db?的時候被完全互質(zhì)統(tǒng)計到,倒序枚舉 b b b并枚舉約數(shù)更新即可。

事實上我們并不需要莫反,其本質(zhì)只是一種容斥,同樣定義 f i f_i fi?表示 g c d ( k , b ) = 1 gcd(k, b) = 1 gcd(k,b)=1時, b = i b = i b=i的合法方案數(shù), 容斥總方案數(shù) ? g c d ( k , b ) = 2 / 3 / 4.... 容斥總方案數(shù) - gcd(k, b) = 2/3/4.... 容斥總方案數(shù)?gcd(k,b)=2/3/4....,所以 f i = ( t i ) / ( 2 l ) ? ∑ j ∣ i f j f_i = (ti) / (2l) - \sum_{j | i} f_j fi?=(ti)/(2l)?ji?fj?, 每個 g c d ( k , b ) ! = 1 gcd(k, b) != 1 gcd(k,b)!=1的答案會被 b b b的某個約數(shù)d在 g c d ( k ′ , d ) gcd(k', d) gcd(k,d)的時候更新, 所以最后的答案就是 ∑ f j [ j ∣ b ] \sum f_j [j | b] fj?[jb]文章來源地址http://www.zghlxwxcb.cn/news/detail-531510.html

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
using ull=unsigned long long;
using ll=long long;
const int mod= 998244353,G=3;//??
const int maxn=2e5+5;
template<typename T>
void read(T &f){ 
    f=0;T fu=1;char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1;c=getchar();}
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+(c&15);c=getchar();}
    f*=fu;
}

template<typename T>
void print(T x){ 
    if(x<0)putchar('-'),x=-x;
    if(x<10)putchar(x+48);
    else print(x/10),putchar(x%10+48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}


inline int Add(int x,int y){ 
    x+=y;
    if(x>=mod)x-=mod;
    return x;
}

inline int Sub(int x,int y){ 
    x-=y;
    if(x<0)x+=mod;
    return x;
}

inline ll mul(ll x,ll y){ return 1ll*x*y%mod;}

ll mypow(int a,int b){ 
    int ans=1;
    while(b){ 
        if(b&1)ans=mul(ans,a);
        a=mul(a,a);
        b>>=1;
    }
    return ans;
}

namespace Poly{ 
    typedef vector<ll>poly;
    poly roots,rev;
    void getRevRoot(int base){ 
        int lim=1<<base;
        if((int)roots.size()==lim)return;
        roots.resize(lim);rev.resize(lim);
        for(int i=1;i<lim;++i)rev[i]=(rev[i>>1]>>1)|((i&1)<<(base-1));
        for(int mid=1;mid<lim;mid<<=1){ 
            int wn=mypow(G,(mod-1)/(mid<<1));
            roots[mid]=1;
            for(int i=1;i<mid;++i)roots[mid+i]=mul(roots[mid+i-1],wn);
        }
    }
    
    void ntt(poly&a,int base){ 
        int lim=1<<base;
        for(int i=0;i<lim;++i)if(i<rev[i])swap(a[i],a[rev[i]]);
        for(int mid=1;mid<lim;mid<<=1){ 
            for(int i=0;i<lim;i+=(mid<<1)){ 
                for(int j=0;j<mid;++j){ 
                    int x=a[i+j],y=mul(a[i+j+mid],roots[j+mid]);
                    a[i+j]=Add(x,y);
                    a[i+j+mid]=Sub(x,y);
                }
            }
        }
    }

    poly operator*(poly a,poly b){ 
        int lim=(int)a.size()+(int)b.size()-1,base=0;
        while((1<<base)<lim)++base;
        a.resize(1<<base);b.resize(1<<base);
        getRevRoot(base);
        ntt(a,base);ntt(b,base);
        for(int i=0;i<(1<<base);++i)a[i]=mul(a[i],b[i]);
        ntt(a,base);
        reverse(a.begin()+1,a.end());
        a.resize(lim);
        int inv=mypow(1<<base,mod-2);
        for(int i=0;i<lim;++i)a[i]=mul(a[i],inv);
        return a;
    }
    poly polyInv(poly f,int base){ 
        int lim=1<<base;
        f.resize(lim);
        if(lim==1){ 
            poly ans(1,mypow(f[0],mod-2));
            return ans;
        }
        poly g(1<<base,0),g0=polyInv(f,base-1),tmp=g0*g0*f;
        for(int i=0;i<(1<<(base-1));++i)g[i]=Add(g0[i],g0[i]);
        for(int i=0;i<(1<<base);++i)g[i]=Sub(g[i],tmp[i]);
        return g;
    }
    poly polyInv(poly f){ 
        int lim=(int)f.size(),base=0;
        while((1<<base)<lim)++base;
        f=polyInv(f,base);f.resize(lim);
        return f;
    }
    
    poly operator+(const poly&a,const poly&b){
        poly c=a;
        c.resize(max(a.size(),b.size()));
        int lim=(int)b.size();
        for(int i=0;i<lim;++i)c[i]=Add(c[i],b[i]);
        return c;
    }

    poly operator-(const poly&a,const poly&b){ 
        poly c=a;
        c.resize(max(a.size(),b.size()));
        int lim=(int)b.size();
        for(int i=0;i<lim;++i)c[i]=Sub(c[i],b[i]);
        return c;
    }

    poly operator*(const int&b,const poly&a){ 
        poly c=a;
        int lim=(int)a.size();
        for(int i=0;i<lim;++i)c[i]=mul(b,c[i]);
        return c;
    }
}

using namespace Poly;
const int del = 2e5;
const int M = 4e5 + 5;
int v[maxn * 2 + 5], mu[maxn * 2 + 5];

bool is[maxn << 1];

vector<int> pr;

ll dp[maxn << 1];

void init() {
    mu[1] = 1;
    for (int i = 2; i < 2 * maxn; ++i) {
        if (!v[i])
            pr.emplace_back(i), mu[i] = -1;
        for (int j = 0; j < pr.size() && i * pr[j] < 2 * maxn; ++j) {
            v[i * pr[j]] = 1;
            if (i % pr[j] == 0) {
                mu[i * pr[j]] = 0;
                break;
            }
            mu[i * pr[j]] = -mu[i];
        }
    }
}

const int P = 1e9 + 7;
vector<int> fac[maxn << 1];

ll mxk[maxn << 1];

int main() {
    IOS
    init();
    int l, t, n;
    cin >> l >> t >> n;
    int mx = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
        mx = max(mx, v[i]);
    }
    poly a(mx + 1, 0), b(del + 1, 0);
    for (int i = 1; i <= n; ++i) {
        a[v[i]]++, b[del - v[i]]++;
    }
    poly A = a * a, B = a * b;
    for (int i = 1; i <= n; ++i) {
        A[2 * v[i]]--;
    }
    for (int i = 1; i <= 2 * mx; ++i) {
        if (A[i]) {
            is[i] = 1;
        }
    }
    for (int i = 1; i <= mx; ++i) {
        if (B[i + del])
            is[i] = 1;
    }
    for (int i = 2 * mx; i >= 1; --i)
        for (int j = i; j <= 2 * mx; j += i)
            is[i] |= is[j];
            // fac[j].emplace_back(i);
    ll ans = 0;
    // for (int i = 2 * mx; i; --i) {
    //     if (is[i]) {
    //         mxk[i] = ((ll) t * i) / (2 * l);
    //     }
    //     for (auto u : fac[i]) {
    //         ans = (ans + mu[u] * (mxk[i] / u) % P) % P;
    //         if (ans >= P)
    //             ans -= P;
    //         if (ans < 0)
    //             ans += P;
    //         mxk[i / u] = max(mxk[i / u], mxk[i] / u);
    //     }
    // }
    for (int i = 1; i <= 2 * mx; ++i) {
        dp[i] = (dp[i] + ((ll) t * i) / (2 * l)) % P;
        if (is[i])
            ans = (ans + dp[i]) % P;
        for (int j = 2 * i; j <= 2 * mx; j += i) {
            dp[j] = (dp[j] - dp[i] + P) % P;
        }
    }
    cout << ans;
    return 0;
}

到了這里,關(guān)于Educational Codeforces Round 151 (Rated for Div. 2)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務器費用

相關(guān)文章

  • Educational Codeforces Round 154 (Rated for Div. 2)(A—C)

    從1到9,每個數(shù)后面都可以加一個數(shù)構(gòu)成一個含有兩個數(shù)的質(zhì)數(shù),只需要從s[1]~s[9]中找到一個數(shù)與s[0]構(gòu)成質(zhì)數(shù)即可 觀察樣例即可發(fā)現(xiàn)兩個字符串只要在相同位置都有 01 存在就能成功實現(xiàn)轉(zhuǎn)換后兩個字符串相等 可以先假設字符串是可以成立的,那么接下來就判斷它什么時間是

    2024年02月10日
    瀏覽(22)
  • Educational Codeforces Round 154 (Rated for Div. 2)(A—D)

    從1到9,每個數(shù)后面都可以加一個數(shù)構(gòu)成一個含有兩個數(shù)的質(zhì)數(shù),只需要從s[1]~s[9]中找到一個數(shù)與s[0]構(gòu)成質(zhì)數(shù)即可 觀察樣例即可發(fā)現(xiàn)兩個字符串只要在相同位置都有 01 存在就能成功實現(xiàn)轉(zhuǎn)換后兩個字符串相等 可以先假設字符串是可以成立的,那么接下來就判斷它什么時間是

    2024年02月10日
    瀏覽(35)
  • Educational Codeforces Round 135 (Rated for Div. 2)C. Digital Logarithm(思維)

    Educational Codeforces Round 135 (Rated for Div. 2)C. Digital Logarithm(思維)

    C. Digital Logarithm 給兩個長度位 n n n 的數(shù)組 a a a 、 b b b ,一個操作 f f f 定義操作 f f f 為, a [ i ] = f ( a [ i ] ) = a [ i ] a[i]=f(a[i])=a[i] a [ i ] = f ( a [ i ]) = a [ i ] 的位數(shù) 求最少多少次操作可以使 a 、 b a、b a 、 b 兩個數(shù)組變得完全相同 性質(zhì): 對于任何數(shù),經(jīng)過兩次操作我們一定可以

    2024年02月20日
    瀏覽(18)
  • 【每日一題】—— B. Ternary String (Educational Codeforces Round 87 (Rated for Div. 2))

    【每日一題】—— B. Ternary String (Educational Codeforces Round 87 (Rated for Div. 2))

    ??博客主頁: PH_modest的博客主頁 ??當前專欄: 每日一題 ??其他專欄: ?? 每日反芻 ?? C++跬步積累 ?? C語言跬步積累 ??座右銘: 廣積糧,緩稱王! 題目大意:給你一串由1、2、3組成的數(shù)組,讓你求一個最短的子串,要求這個子串包含1、2、3 題目鏈接:B. Ternary String

    2024年02月16日
    瀏覽(18)
  • Educational Codeforces Round 157 (Rated for Div. 2) F. Fancy Arrays(容斥+組合數(shù)學)

    題目 稱一個長為n的數(shù)列a是fancy的,當且僅當: 1. 數(shù)組內(nèi)至少有一個元素在[x,x+k-1]之間 2. 相鄰項的差的絕對值不超過k,即 t(t=50)組樣例,每次給定n(1=n=1e9),x(1=x=40), 求fancy的數(shù)組的數(shù)量,答案對1e9+7取模 思路來源 靈茶山艾府群 官方題解 題解 看到 至少 的字眼,首先想到容斥,

    2024年02月05日
    瀏覽(20)
  • Educational Codeforces Round 161 (Rated for Div. 2) E. Increasing Subsequences 動態(tài)規(guī)劃逼近,二進制拆分補充,注意嚴格遞增

    Problem - E - Codeforces 目錄 推薦視頻: 題意: 細節(jié)(我踩得沒什么價值的坑): 思路: 對樣例3 (X = 13)做解釋: —————— 總思路: —————— 動態(tài)規(guī)劃逼近: —————— 二進制拆分補充剩余: 核心代碼:? E_嗶哩嗶哩_bilibili 其實有一些細節(jié)說的不是特別清楚好

    2024年02月22日
    瀏覽(22)
  • Educational Codeforces Round 161 (Rated for Div. 2) E題 動態(tài)規(guī)劃逼近,二進制拆分補充,注意嚴格遞增strictly increasing

    Problem - E - Codeforces 目錄 推薦視頻: 題意: 細節(jié)(我踩得沒什么價值的坑): 思路: 對樣例3 (X = 13)做解釋: —————— 總思路: —————— 動態(tài)規(guī)劃逼近: —————— 二進制拆分補充剩余: 核心代碼:? E_嗶哩嗶哩_bilibili 其實有一些細節(jié)說的不是特別清楚好

    2024年01月24日
    瀏覽(17)
  • Educational Codeforces Round 145 Div. 2 題解

    目錄 A. Garland(簽到) 題面翻譯 思路: 代碼 B. Points on Plane(數(shù)學) 題面翻譯 思路: 代碼 C. Sum on Subarray(構(gòu)造) 題面翻譯: 思路: 代碼 D. Binary String Sorting 題面翻譯 思路: 代碼 You have a garland consisting of?4?colored light bulbs, the color of the?i-th light bulb is?si. Initially, all the l

    2023年04月09日
    瀏覽(17)
  • Educational Codeforces Round 147 div2題解

    目錄 A. Matching(簽到) 思路: 代碼:? B. Sort the Subarray(簽到) 思路: 代碼: C. Tear It Apart(枚舉) 思路: 代碼: D. Black Cells(模擬) 思路: ?代碼一: 代碼二:(模仿自\\\"AG\\\"佬) An?integer template?is a string consisting of digits and/or question marks. A positive (strictly greater than?0) in

    2023年04月21日
    瀏覽(20)
  • Educational Codeforces Round 134 (Div.2) D 題解

    D. Maximum AND 給定兩組序列 (a) (b) ,長度為 (n) ,現(xiàn)有一新序列 (c) ,長度也為 (n) 。 其中, (c_i = a_i oplus b_i) 。 定義 (f(a,b) = c_1c_2……c_n) 。 現(xiàn)在你可以隨意編排 (b) 序列的順序,求 (f(a,b)) 的最大值。 以下位運算均是二進制。 由于按位與的運算結(jié)果是越來越小的

    2024年02月06日
    瀏覽(17)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包