VP Codeforces Round #691 (Div. 2)

Posted XINNNNNNNYU

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VP Codeforces Round #691 (Div. 2)相关的知识,希望对你有一定的参考价值。

A. Red-Blue Shuffle

题意

有n张牌,有红蓝两个数字(个位),对于一个排列,红蓝分别组成一个n位数,哪个数字大则谁赢,相同的话打平。问最后红蓝两方谁赢的概率更大。

思路

每张牌的红蓝数字是绑定的,我们只需要统计每张牌红数字更大和蓝数字更大的个数,最后看哪种情况更多即可。

代码

#include<bits/stdc++.h>
using namespace std;


#define INF 0x3f3f3f3f3f3f3f3f
#define int long long
#define endl "\\n"
#define rep(pigstar,a,b) for (int pigstar = (a); pigstar <= (b); pigstar ++)
#define per(pigstar,a,b) for (int pigstar = (a); pigstar >= (b); pigstar --)
#define ReadInt(pigstar,a,b) for (int i = (a); i <= (b); i ++) cin >> pigstar[i];
#define OutInt(pigstar,a,b) for (int i = (a); i <= (b); i ++) cout << pigstar[i] << " \\n"[i==b]
#define all(pigstar) pigstar.begin(),pigstar.end()
#define rvs(pigstar) reverse(pigstar.begin(),pigstar.end())
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define pb push_back
#define SZ(pigstar) ((int)(pigstar).size())
#define MP make_pair
#define x first
#define y second


#define CN puts("NO")
#define CY puts("YES")



//----------------debug---------------//
#define debug(args...)  string _s = #args; auto end_pos = remove(_s.begin(), _s.end(), ' '); _s.erase(end_pos, _s.end()); replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cout << "\\n";
void err(istream_iterator<string> it) 
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
    cerr << (*it) << " = " << a << "   ";
    err(++it, args...);

//----------------debug---------------//



typedef double db;
typedef long long ll;
typedef unsigned long long ull;

const int maxn = 1e6+7;
const int mod = 1e9+7;
const double eps = 1e-6;

int qmi(int a, int k, int p)int res = 1;while (k)if (k & 1) res = (ll)res * a % p;a = (ll)a * a % p;k >>= 1;return res;
int qpow(int a,int b)int res = 1;while(b)if(b&1) res *= a;b>>=1;a*=a;return res;
int mo(int x,int p)return x = ((x%p)+p)%p;
int gcd(int a,int b)return b?gcd(b,a%b):a;
int lowbit(int x)  return (-x)&x; 
int fac[maxn], invfac[maxn];
void fact_init() 
    fac[0] = 1;
    for (int i = 1; i < maxn; i ++) 
        fac[i] = (fac[i - 1] * i) % mod;
    
    invfac[maxn - 1] = qmi(fac[maxn - 1], mod - 2, mod);
    for (int i = maxn - 1; i; i --) 
        invfac[i - 1] = (invfac[i] * i) % mod;
    

int C (int n, int m) 
    return ((fac[n] * invfac[m]) % mod * invfac[n - m]) % mod;



int dx[] = 0,0,1,-1, dy[] = 1,-1,0,0;

int T = 1,N,M,K,Q;



void solve()
    cin >> N;
    string a,b;
    cin >> a >> b;
    int num = 0;
    rep(i,0,N-1) 
        if (a[i] != b[i]) 
            if (a[i] > b[i]) 
                num ++;
             else num --;
        
    
    if (!num) puts("EQUAL");
    else 
        if (num < 0) puts("BLUE");
        else puts("RED");
    
    

signed main()

    cin >> T;
    // fact_init();
    for (int i = 1; i <= T; i ++) solve();
    return (0-0); //<3
 

B. Move and Turn

题意

你当前在(0,0)你可以走n步,每次选择上下左右其中一个方向,但是相邻两步不能是同一条线,必须要垂直。即上一步走了左右,这一步必须走上下;上一步走了上下,这一步必须走左右。问n步后能到达的点有几种可能,

思路

因为上下和左右交替进行,则

  • n为偶数

    设n = 2k

    则上下走了k步,左右走了k步。纵向上能到达的点有k + 1个,同理横向能到达的点有k + 1个,最后由(k + 1) * (k + 1)个可能点

  • n位奇数

    设n = 2k + 1

    • 若上下走了2k步,左右走了2k + 1步。纵向上能到达的点有k + 1个,同理横向能到达的点有k + 2个,最后由(k + 1) * (k + 2)个可能点
    • 若上下走了2k + 1步,左右走了2k步。纵向上能到达的点有k + 2个,同理横向能到达的点有k + 1个,最后由(k + 1) * (k + 2)个可能点

    所以最后共有2 * (k + 1) * (k + 2) 个可能点

代码

#include<bits/stdc++.h>
using namespace std;


#define INF 0x3f3f3f3f3f3f3f3f
#define int long long
#define endl "\\n"
#define rep(pigstar,a,b) for (int pigstar = (a); pigstar <= (b); pigstar ++)
#define per(pigstar,a,b) for (int pigstar = (a); pigstar >= (b); pigstar --)
#define ReadInt(pigstar,a,b) for (int i = (a); i <= (b); i ++) cin >> pigstar[i];
#define OutInt(pigstar,a,b) for (int i = (a); i <= (b); i ++) cout << pigstar[i] << " \\n"[i==b]
#define all(pigstar) pigstar.begin(),pigstar.end()
#define rvs(pigstar) reverse(pigstar.begin(),pigstar.end())
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define pb push_back
#define SZ(pigstar) ((int)(pigstar).size())
#define MP make_pair
#define x first
#define y second


#define CN puts("NO")
#define CY puts("YES")



//----------------debug---------------//
#define debug(args...)  string _s = #args; auto end_pos = remove(_s.begin(), _s.end(), ' '); _s.erase(end_pos, _s.end()); replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cout << "\\n";
void err(istream_iterator<string> it) 
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
    cerr << (*it) << " = " << a << "   ";
    err(++it, args...);

//----------------debug---------------//



typedef double db;
typedef long long ll;
typedef unsigned long long ull;

const int maxn = 1e6+7;
const int mod = 1e9+7;
const double eps = 1e-6;

int qmi(int a, int k, int p)int res = 1;while (k)if (k & 1) res = (ll)res * a % p;a = (ll)a * a % p;k >>= 1;return res;
int qpow(int a,int b)int res = 1;while(b)if(b&1) res *= a;b>>=1;a*=a;return res;
int mo(int x,int p)return x = ((x%p)+p)%p;
int gcd(int a,int b)return b?gcd(b,a%b):a;
int lowbit(int x)  return (-x)&x; 
int fac[maxn], invfac[maxn];
void fact_init() 
    fac[0] = 1;
    for (int i = 1; i < maxn; i ++) 
        fac[i] = (fac[i - 1] * i) % mod;
    
    invfac[maxn - 1] = qmi(fac[maxn - 1], mod - 2, mod);
    for (int i = maxn - 1; i; i --) 
        invfac[i - 1] = (invfac[i] * i) % mod;
    

int C (int n, int m) 
    return ((fac[n] * invfac[m]) % mod * invfac[n - m]) % mod;



int dx[] = 0,0,1,-1, dy[] = 1,-1,0,0;

int T = 1,N,M,K,Q;



void solve()
    cin >> N;
    vector<int> a(N);
    int ans = 0;
    if (N & 1) 
        int y = N - 1;
        y /= 2;
        cout << (y Codeforces Round #691 (Div. 1)

Codeforces Round #691 (Div. 1)

Codeforces Round #691 (Div. 2)

Codeforces Round #691 (Div. 2)

上分准备 VP Codeforces Round #762 (Div. 3) 4题ABCE

Codeforces Round #485 Div. 1 vp记