CodeForces 1009 div2 ABCD / Educational Codeforces Round 47 div2 ABCD

A Game Shopping

一眼题,随便以一个文本作为基础,扫描另外一个即可

/**
 * @Date:   16-Jul-2018
 * @Email:  zengsw_study@qq.com
 * @Filename: A.cpp
 * @Last modified time: 17-Jul-2018
 * @Copyright: Copr. 2018 EndlessLethe. All rights reserved.
 * @Description:
 */

#include <stdlib.h>
#include <iostream>
using namespace std;

const int MAXN = 1000;
int a[MAXN], b[MAXN];

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> b[i];
    }
    int j = 0, i = 0;
    for (i = 0; i 
Read the rest

前言

这是我在上学期面试中遇到的一道概率题,现场没做出来,让面试官快速进入算法题环节了= =
今天突然联想到最近在看的内容,一下子顿悟了,开心
其实这道题是语文题

题面

甲认为一道题是对的,且这道题是对的概率为0.9。乙认为一道题是对,且这道题是对的概率为0.8。求甲乙都认为一道题为对,且这道题确实为对的概率?

Note:答案不等于0.72… Read the rest

A. Scarborough Fair

多次区间修改字符串
解法:朴素暴力

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

string str, s;
int n, m, x, y;

int main() {
    //ios_base::sync_with_stdio(0);cin.tie(0);
    #ifdef LOCAL
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif
    cin >> n >> m;
    cin >> str;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        x--, y--;
        cin >> s[0] >> s[1];
        for (int j = x; j <= y; j++) {
            if (str[j] == s[0]) str[j] = s[1];
        }
    }
    cout << str << endl;
    return 0;
}

B. Chtholly’s request

偶数位回文数
解法:利用高n/2位构造回文数

#include <bits/stdc++.h>
Read the rest