CF1151div2(丸553)

CF1151div2(丸553)

アイデアのタイトルのコンテスト

A

いくつかの例を考えてみましょう、死に期待していませんでした

B

私は50,000をランダム化したように見えます、合格しているようだ何の解決策を見つけることはなかったです

何気なく感じることはファック+分類は、道の上に議論することができます

#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
const int N = 505;
inline int read(){
    int v = 0,c = 1;char ch = getchar();
    while(!isdigit(ch)){
        if(ch == '-') c = -1;
        ch = getchar();
    }
    while(isdigit(ch)){
        v = v * 10 + ch - 48;
        ch = getchar();
    }
    return v * c;
}
int a[N][N];
int b[N][N];
int tot;
int s[N];
int n,m;
inline bool pan(){
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
            if(b[i][j] != 1) return 0;
    return 1;
}
inline bool check(){
    if(pan()){
        if(n & 1){
            for(int i = 1;i <= n;++i) s[++tot] = 1;
            return 1;   
        }
        else return 0;
    }
    
}
int main(){
    srand(time(0));
    n = read(),m = read();
    for(int i = 1;i <= n;++i) for(int j = 1;j <= m;++j) a[i][j] = read();
    for(int t = 1;t <= 50000;++t){
        int now = 0;
        for(int i = 1;i < n;++i) s[i] = rand() % m + 1,now ^= a[i][s[i]];
        for(int i = 1;i <= m;++i){
            if((now ^ a[n][i]) != 0){
                s[n] = i;
                printf("TAK\n");
                for(int j = 1;j <= n;++j) printf("%d ",s[j]);
                return 0;
            }
        }
    }
    printf("NIE\n");
    return 0;
}

C

〜スパイシーなチキンCFでも__int128サポートしていませ~~

我々は検討するセクションに、すべてのログをブロックします。

各ブロック内で実際の演算シーケンスであります

私たちは、数列の和の公式を使用することができます

以下のために\(L、Rは\)を見つけるためにどのような接頭辞と

また、アイテムの数が大きくなる可能性があり、それは(私はこのためWAの午前)%モッズなければなりません

#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
const LL mod = 1e9 + 7;
inline LL read(){
    LL v = 0,c = 1;char ch = getchar();
    while(!isdigit(ch)){
        if(ch == '-') c = -1;
        ch = getchar();
    }
    while(isdigit(ch)){
        v = v * 10 + ch - 48;
        ch = getchar();
    }
    return v * c;
}
LL L,R;
LL sum[129];
LL shou[129];
inline LL quick(LL x,LL y){
    LL res = 1;
    while(y){
        if(y & 1) res = res * x % mod;
        y >>= 1;
        x = x * x % mod;    
    }   
    return res;
}
LL inv2 = quick(2,mod - 2);
inline LL work(LL x){
    if(x == 0) return 0;
    LL cnt = 0;
    LL gg = 0;
    LL ans = 0;
    while(gg + (1ll << cnt) <= x){
        ans = (ans + sum[cnt]) % mod;
        gg += (1ll << cnt);
        cnt++;  
    }
    if(gg != x){
        LL rest = (x - gg) % mod;
        LL rail = (shou[cnt] + (rest - 1) * 2 % mod) % mod;
        ans = (ans + (shou[cnt] + rail) % mod * rest % mod * inv2 % mod) % mod;
    }
    return ans;
}
int main(){
    L = read(),R = read();
    LL now = 0;
    LL base = 0;
    LL ji = 1;
    LL ou = 2; 
    long long rr = R;
    do{
        rr -= (1ll << base);
    //  printf("%lld\n",rr);
        if(base & 1){
            shou[base] = ou;
            sum[base] = (ou + (ou + 2 * (quick(2,base) - 1) % mod) % mod) % mod * quick(2,base) % mod * inv2 % mod;
            ou = (ou + 2 * (quick(2,base)) % mod) % mod;
        }
        else{
            shou[base] = ji;
            sum[base] = (ji + (ji + 2 * (quick(2,base) - 1) % mod) % mod) % mod * quick(2,base) % mod * inv2 % mod;
            ji = (ji + 2 * (quick(2,base)) % mod) % mod;
        }
        base++;
    }while(rr > 0);
//  for(int i = 0;i <= base;++i) printf("%lld\n",(long long)(sum[i]));
    long long ans = ((work(R) - work(L - 1) + mod) % mod + mod) % mod;
    printf("%lld\n",(long long)ans); 
    return 0;
}

D

式見出され、そしてのみすることができる\(a_iを-b_iの\)の値

そして幸せなソートの寄与を計算します

#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
const LL mod = 1e9 + 7;
inline LL read(){
    LL v = 0,c = 1;char ch = getchar();
    while(!isdigit(ch)){
        if(ch == '-') c = -1;
        ch = getchar();
    }
    while(isdigit(ch)){
        v = v * 10 + ch - 48;
        ch = getchar();
    }
    return v * c;
}
LL L,R;
LL sum[129];
LL shou[129];
inline LL quick(LL x,LL y){
    LL res = 1;
    while(y){
        if(y & 1) res = res * x % mod;
        y >>= 1;
        x = x * x % mod;    
    }   
    return res;
}
LL inv2 = quick(2,mod - 2);
inline LL work(LL x){
    if(x == 0) return 0;
    LL cnt = 0;
    LL gg = 0;
    LL ans = 0;
    while(gg + (1ll << cnt) <= x){
        ans = (ans + sum[cnt]) % mod;
        gg += (1ll << cnt);
        cnt++;  
    }
    if(gg != x){
        LL rest = (x - gg) % mod;
        LL rail = (shou[cnt] + (rest - 1) * 2 % mod) % mod;
        ans = (ans + (shou[cnt] + rail) % mod * rest % mod * inv2 % mod) % mod;
    }
    return ans;
}
int main(){
    L = read(),R = read();
    LL now = 0;
    LL base = 0;
    LL ji = 1;
    LL ou = 2; 
    long long rr = R;
    do{
        rr -= (1ll << base);
    //  printf("%lld\n",rr);
        if(base & 1){
            shou[base] = ou;
            sum[base] = (ou + (ou + 2 * (quick(2,base) - 1) % mod) % mod) % mod * quick(2,base) % mod * inv2 % mod;
            ou = (ou + 2 * (quick(2,base)) % mod) % mod;
        }
        else{
            shou[base] = ji;
            sum[base] = (ji + (ji + 2 * (quick(2,base) - 1) % mod) % mod) % mod * quick(2,base) % mod * inv2 % mod;
            ji = (ji + 2 * (quick(2,base)) % mod) % mod;
        }
        base++;
    }while(rr > 0);
//  for(int i = 0;i <= base;++i) printf("%lld\n",(long long)(sum[i]));
    long long ans = ((work(R) - work(L - 1) + mod) % mod + mod) % mod;
    printf("%lld\n",(long long)ans); 
    return 0;
}

E

まず、少し\(トリック\)

ブロック通信ポイントの数= - エッジの数

だから、答えはポイント数とマイナス側の和となります

ポイントの\(iは\) 彼の貢献がなければならない
\ [a_iを×(N - a_iを
+ 1)\]は、左右のポイントのポイント値が正当であることです

彼の二つのリンクのエッジ点が存在されている場合にのみ
\ [分(a_iを、A_ { - \ I + 1})*(MAX(a_iを、A_ {I + 1})+ 1、N)]を

おすすめ

転載: www.cnblogs.com/wyxdrqc/p/11402982.html