Codeforces Round 1034 (Div. 3)

初阶必刷编程50题 一 、基本数据类型 1、A+B问题 public class Solution { /** * @param a: An integer * @param b: An integer * @return: The sum of a and b */ public int aplusb(int a, int b) { return a+b; } } 2、反转一个三位整数 public int reverseInteger 阅读详情

比赛链接如下:https://codeforces.com/contest/2123 

A. Blackboard Game

Initially, the integers from 00 to n−1 are written on a blackboard.

In one round,

  • Alice chooses an integer a on the blackboard and erases it;
  • then Bob chooses an integer b on the blackboard such that a+b≡3(mod4) and erases it.

Rounds take place in succession until a player is unable to make a move — the first player who is unable to make a move loses. Determine who wins with optimal play.

We define that x≡y(mod m) whenever x−y is an integer multiple of mm.

解题思路:

其实根据输入输出也能大概猜出来

(a+b-3)%4=0, Alice去拿一个数, 然后Bob去进行配对, 谁先操作不了, 谁就输了

eg:

n=4, 0 1 2 3

Alice拿0, Bob拿3进行配对

Alice拿1, Bob拿2进行配对

Bob赢

n=5, 0 1 2 3 4

这里Alice先拿0还是4无所谓,

Alice赢

n=8 0 1 2 3 ; 4 5 6 7

Bob赢

n%4==0, Bob赢

n%4!=0, Alice赢

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
    ll n;
    cin >> n;
    if (n % 4 == 0) {
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
}
int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

 B. Tournament

You are given an array of integers a1,a2,…,an. A tournament is held with nn players. Player i has strength aiai.

While more than k players remain,

  • Two remaining players are chosen at random;
  • Then the chosen player with the lower strength is eliminated. If the chosen players have the same strength, one is eliminated at random.

Given integers j and k (1≤j,k≤n), determine if there is any way for player j to be one of the last k remaining players.

解题思路:

当k=1时, aj要想留下来, 只能是数组最大值, 

k>1时, aj肯定是能留下来的

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
    int n, j, k;
    cin >> n >> j >> k;
    j--;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (k == 1) {
        int mx = *max_element(a.begin(), a.end());
        if (a[j] == mx) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    } else {
        cout << "YES" << endl;
    }
}
int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

 C. Prefix Min and Suffix Max

You are given an array aa of distinct integers.

In one operation, you may either:

  • choose a nonempty prefix of aa and replace it with its minimum value, or
  • choose a nonempty suffix of aa and replace it with its maximum value.

Note that you may choose the entire array a.

For each element ai, determine if there exists some sequence of operations to transform aa into [ai]; that is, make the array a consist of only one element, which is aiai. Output your answer as a binary string of length nn, where the ii-th character is 1 if there exists a sequence to transform aa into [ai], and 0 otherwise.

A prefix of an array is a subarray consisting of the first kk elements of the array, for some integer k.

A suffix of an array is a subarray consisting of the last k elements of the array, for some integer k.

给你一个不同整数的数组。
在一个操作中,您可以选择a的非空前缀*并将其替换为其最小值,或者选择a的非空前缀*并将其替换为其最大值。
注意,您可以选择整个数组a。对于每个元素a¿,确定是否存在一些操作序列将a转换为[a´];
也就是说,使数组只包含一个元素,即a。将您的答案输出为长度为n的二进制字符串,如果存在将a转换为[ai]的序列,则第i个字符为1,否则为0。
对于整数k,数组的前缀是由数组的前k个元素组成的子数组。数组的后缀是由数组的最后k个元素组成的子数组。 

解题思路:

​​​​​​1.前缀最小值:元素 ai 是从数组开头到 i 位置(a1 到 ai)的最小值。

2.后缀最大值:元素 ai 是从 i 位置到数组结尾(ai 到 an)的最大值。

3.可保留条件:如果 ai 是前缀最小值或后缀最大值,则存在操作序列将数组缩减为 [ai];否则,无法保留。

eg: 数组 [1, 3, 5, 4, 7, 2],输出 100011

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1), pre(n + 1, INT_MAX), suf(n + 2);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pre[i] = min(pre[i - 1], a[i]);
    }
    for (int i = n; i >= 1; i--) {
        suf[i] = max(suf[i + 1], a[i]);
    }
    for (int i = 1; i <= n; i++) {
        cout << (a[i] == pre[i] || a[i] == suf[i] ? 1 : 0);
    }
    cout << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

 D. Binary String Battle

Alice and Bob are given a binary string s of length n, and an integer k (1≤k<n).

Alice wins if she is able to transform all characters of ss into zeroes. If Alice is unable to win in a finite number of moves, then Bob wins.

Alice and Bob take turns, with Alice going first.

  • On Alice's turn, she may choose any subsequence∗∗ of length k in s, then set all characters in that subsequence to zero.
  • On Bob's turn, he may choose any substring†† of length k in ss, then set all characters in that substring to one.

Note that Alice wins if the string consists of all zeros at any point during the game, including in between Alice's and Bob's turns.

Determine who wins with optimal play.

∗∗A subsequence of a string s is a set of characters in s. Note that these characters do not have to be adjacent.

††A substring of a string s is a contiguous group of characters in s. Note that these characters must be adjacent.

解题思路:

1.Alice必赢的条件:
如果初始 cnt(s 中 1 的数量) ≤ k,Alice 一次就能把所有 1 清掉 —— 赢。
如果 n < 2*k,则 Bob 无法每次维护 cnt > k 的策略(因为没地方藏一个"额外的 1")—— Alice 
2. Bob必赢的条件:
如果 cnt > k 且 n ≥ 2*k,Bob 总能维护至少一个额外的 1,并总能抵消 Alice 的操作 —— 赢。 

因为你要找两个不重叠的长度为 k 的子串,至少需要长度 2k

否则他怎么也得和 Alice 的[清除区]发生重叠,Alice 就能全清了

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve(){
    int n, k, cnt = 0;
    string s;
    cin >> n >> k >> s;
    for(char c : s){
        if(c == '1'){
            cnt++;
        }
    }
    cout << (cnt <= k || n < 2*k ? "Alice" : "Bob") << '\n';
}
 
int main(){
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

E. MEX Count

Define the MEX (minimum excluded value) of an array to be the smallest nonnegative integer not present in the array. For example,

  • MEX([2,2,1])=0 because 0 is not in the array.
  • MEX([3,1,0,1])=2 because 0 and 1 are in the array but 2 is not.
  • MEX([0,3,1,2])=4 because 0, 1, 2, and 3 are in the array but 44 is not.

You are given an array aa of size n of nonnegative integers.

For all k (0≤k≤n), count the number of possible values of MEX(a) after removing exactly kk values from a.

解题思路:MEX是数组a中的最小非负整数

eg:

数组a: 

0 1 2 3 4 5 .. n

出现次数分别为:

1 2 1 3 0 2 .. 5

比如MEX=1, 我们最少需要删除2个1

最多为n-1 (1之前每个数字次数剩1个,1后面全删了,最后剩1个数字,删除n-1个)

就是你删除任意个[cntx, n-x] 都能得到x

题目是删除k个数字, mex的可能性

然后差分即可

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n), cnt(n + 1, 0);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            if (a[i] <= n) {
                cnt[a[i]]++;
            }
        }
        vector<int> ok(n + 1, false);
        ok[0] = true;
        for (int m = 1; m <= n; m++) {
            ok[m] = ok[m - 1] && (cnt[m - 1] > 0);
        }
        vector<int> diff(n + 2, 0);
        for (int m = 0; m <= n; m++) {
            if (!ok[m])
                break;
            int L = cnt[m];
            int R = n - m;
            if (L <= R) {
                diff[L] += 1;
                diff[R + 1] -= 1;
            }
        }
        vector<int> ans(n + 1);
        int cur = 0;
        for (int k = 0; k <= n; k++) {
            cur += diff[k];
            ans[k] = cur;
        }
        for (int k = 0; k <= n; k++) {
            cout << ans[k] << (k == n ? '\n' : ' ');
        }
    }
    return 0;
}

 F. Minimize Fixed Points

Call a permutation∗ p of length nn good if gcd(pi,i)>1 for all 2≤i≤n. Find a good permutation with the minimum number of fixed points‡‡ across all good permutations of length n. If there are multiple such permutations, print any of them.

∗∗ A permutation of length nn is an array that contains every integer from 1 to n exactly once, in any order.

gcd(x,y) denotes the greatest common divisor (GCD) of x and y.

‡‡A fixed point of a permutation p is an index j (1≤j≤n) such that pj=j.

解题思路:

n=6,

1 4 6 2 5 3

1 2 3 4 5 6

gcd:

1 2 3 2 5 3

fixed points = 2

gcd(pi,i)>1, i>1

i=0, a[0]=1

当n=13,

质数2及其倍数为:2  4  6  8 10 12 

数左移一位, 就可以和下标形成 gcd(pi,i)=2

2 4 6 8 10 12

4 6 8 10 12 2

prime = 3

3 6 9 12

素数越大, 在1-n这个序列中, 倍数的出现次数越少  

prime=5

5 10

只能这两进行轮换, 因此我们从prime比较大 -> prime比较小

prime在比较大的数轮换过后, 后续就不需要进行轮换了

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 1000005;
vector<bool> isp(MAXN, true); // isp[i] = true 表示是素数
void init(int n) {
    isp[0] = isp[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (isp[i]) {
            for (int j = i * i; j <= n; j += i) {
                isp[j] = false;
            }
        }
    }
}

void solve() {
    int n;
    cin >> n;
    init(n);
    vector<int> a(n + 1, -1);
    vector<bool> vis(n + 1, false);
    for (int i = n / 2; i >= 2; i--) {
        if (!isp[i]) {
            continue;
        }
        vector<int> c;   //// 收集所有 i 的倍数
        for (int j = i; j <= n; j += i) {
            if (vis[j]) {
                continue;
            }
            vis[j] = true;
            c.push_back(j);
        }
        // // 构造一个环:c[0]->c[1]->...->c[k-1]->c[0]
        for (int j = 0; j < c.size(); j++) {
            a[c[j]] = c[(j + 1) % c.size()];
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << (a[i] == -1 ? i : a[i]) << " ";
    }
    cout << '\n';
}
int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

G. Modular Sorting

 You are given an integer m (2≤m≤5⋅105) and an array aa consisting of nonnegative integers smaller than m.

Answer queries of the following form:

  • 1 i x: assign ai:=x
  • 2 k: in one operation, you may choose an element aiai and assign ai:=(ai+k)(modm)a — determine if there exists some sequence of (possibly zero) operations to make a nondecreasing.

Note that instances of query 2 are independent; that is, no actual operations are taking place. Instances of query 1 are persistent.

a(modm) is defined as the unique integer bb such that 0≤b<m and a−b is an integer multiple of m.

An array a of size n is called nondecreasing if and only if ai≤ai+1 for all 1≤i<n.

解题思路:

(ai+k)%m 

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 1000100;
vector<bool> isp;
vector<int> primes;

void init(int top) {
    isp.assign(top + 1, true);
    isp[0] = isp[1] = false;
    for (int i = 2; i <= top; ++i) {
        if (isp[i])
            primes.push_back(i);
        for (int j = 0; j < (int)primes.size(); ++j) {
            int p = primes[j];
            if (i * p > top)
                break;
            isp[i * p] = false;
            if (i % p == 0)
                break;
        }
    }
}

map<int, int> factorize(int v) {
    map<int, int> res;
    for (int i = 0; i < (int)primes.size(); ++i) {
        int p = primes[i];
        if (1LL * p * p > v)
            break;
        int cnt = 0;
        while (v % p == 0) {
            cnt++;
            v /= p;
        }
        if (cnt)
            res[p] = cnt;
    }
    if (v > 1)
        res[v] = 1;
    return res;
}

vector<int> get_divisors(int v) {
    map<int, int> f = factorize(v);
    vector<int> res;
    res.push_back(1);
    for (map<int, int>::iterator it = f.begin(); it != f.end(); ++it) {
        int p = it->first, c = it->second;
        int sz = res.size();
        int base = 1;
        for (int i = 0; i < c; ++i) {
            base *= p;
            for (int j = 0; j < sz; ++j) {
                res.push_back(res[j] * base);
            }
        }
    }
    return res;
}

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

void solve() {
    int n, m, qn;
    cin >> n >> m >> qn;

    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    vector<array<int, 3>> q(qn);
    for (int i = 0; i < qn; i++) {
        cin >> q[i][0];
        if (q[i][0] == 1) {
            cin >> q[i][1] >> q[i][2];
        } else {
            cin >> q[i][1];
        }
    }

    vector<int> res(qn, -1);
    vector<int> b(n);

    vector<int> divisors = get_divisors(m);
    for (int d_index = 0; d_index < (int)divisors.size(); ++d_index) {
        int d = divisors[d_index];
        for (int i = 0; i < n; i++) {
            b[i] = a[i] % d;
        }

        int sum = 0;
        for (int i = 0; i + 1 < n; i++) {
            if (b[i] > b[i + 1])
                sum++;
        }

        for (int i = 0; i < qn; i++) {
            if (q[i][0] == 1) {
                int w = q[i][1] - 1;
                int v = q[i][2];
                if (w - 1 >= 0 && b[w - 1] > b[w])
                    sum--;
                if (w + 1 < n && b[w] > b[w + 1])
                    sum--;
                b[w] = v % d;
                if (w - 1 >= 0 && b[w - 1] > b[w])
                    sum++;
                if (w + 1 < n && b[w] > b[w + 1])
                    sum++;
            } else {
                if (gcd(q[i][1], m) == d) {
                    res[i] = sum < m / d;
                }
            }
        }
    }

    for (int i = 0; i < qn; i++) {
        if (res[i] != -1) {
            cout << (res[i] ? "YES" : "NO") << '\n';
        }
    }
}

int main() {
    init(MAXN);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

感谢大家的点赞和关注,你们的支持是我创作的动力!

 

道德经·场景演变算法引擎 v2.0(会员专属) 摘要: 《道德经·场景演变算法引擎v2.0》是一个基于老子81章道德经的智能决策系统,通过四层架构实现自然交互:场景识别引擎(SRE)分析用户状态,道德经智能锚(DIA)匹配对应章节,动态输出引擎(DOE)生成个性化建议,自适应学习层(ASL)持续优化。系统可识别7大核心场景(决策困境/情绪低谷/顺境飘然等),自动匹配最合适的道德经章节(如决策用63章、低谷用58章),输出自然如老友交谈。该系统由诸葛鑫开发,以曾仕强理论为指导,献礼新中国77周年,实现"老大说话→智能匹配→自然输出"的智 阅读详情

相关推荐

BUSCO评估基因组的完整性

因为数据库收集的时候找的就是在不同的物种间都是单拷贝的基因,所以说在评估的物种里面应该也是单拷贝的状态才对。基因组层面评估:先去基因组上预测这些基因,再去做评估,如果说给他是一个注释好的基因集,这个时候提供的是一个蛋白集合,它就直接是去进行同源搜索,再去评估,看BUSCO数据库里面的这些单拷贝基因有或者无;首先,tblastn也是同源搜索,同源搜索之后,去对转录本进行读码框预测,预测完的结果还是去进行hmmsearch的搜索(hmmsearch是做蛋白质结构域搜索的),最终拿到BUSCO评估结果。

qq_64400864的博客 2959

博弈论总结

我只是个搬运工……   博弈论小结 by xaphoenix 写在前面 第一次写一个专题的总结,由于笔者水平有限,所以里面肯定会有很多不恰当之处,希望读者不吝赐教。此外,这个小结中,有大约2000字的直接复制粘贴的知识介绍,有几道题的题目分析或者题意概括来源于网上各位大牛的博客,所以笔者不具有著作权,具体的参考资料在本文最后列出。另外,为了节省页数(准备把这个带到现场),所以排版比较凌乱...

qq1169091731的博客 9257

MinerU安装指南:从源码到验证的完整流程

本文详细介绍了MinerU文档转换工具的安装流程,从源码获取、依赖安装到验证步骤,提供了完整的安装指南和常见问题解决方案。特别适合技术写作者和开发者快速部署这款高效的文档转换工具,提升工作效率。

weixin_29243279的博客 544

#《AI中文版》V3 第 3 章 知情搜索

参考链接:[1] 开源内容:https://github.com/siyuxin/AI-3rd-edition-notes[2]

weixin_46034116的博客 1447

【人工智能】人工智能基础概念、流派、发展史

人工智能初衷就是让计算机能够像人类一样具有自我思考、自我学习、自我决策的能力。依据百度百科上对人工智能定义:人工智能是研究、开发用于模拟、扩展和延伸人的智能的理论、方法、技术及应用系统的一门新的技术学科。人工智能是研究使计算机来模拟人的某些思维过程和智能行为的学科,主要包括计算机实现智能的原理、制造类似于人脑智能的计算机,使计算机能实现更高层次的应用。

WEL测试 1878

c++界面开发入门

c++界面开发 DialogBox MessageBox

jiaodou2的博客 6515

TowardsDataScience 博客中文翻译 2019(一百三十五)

代码重构是对代码进行修改,以提高其可读性和性能。对于性能部分,这意味着您必须调整代码,以减少内存使用或缩短运行时间。首先,让我们完成导入和数据加载。Seaborn 更喜欢这里。当我在 jupyter 笔记本上创建情节时,我使用 seaborn 来设置情节背景。现在我们的导入和数据已经设置好了,让我们来看看我们的 ecdf 绘图功能。*"""**"""*对于速度重构,我们将关注于定义yaxis的地方。注意,我们调用了两次len()来构造yaxis。这导致运行时间不必要的增加。

龙哥盟 3872

本地部署大模型框架 LMStudio和Ollama+WebUI对比

之前我们的辣妈系列文章介绍了很多如何使用Ollama框架+OpenWebUI做很多大模型框架下相关的事情。之后我们也尝试了LMStudio这样一体化的工具。本文介绍下LMStudio 和 Ollama+Web UI 各有优劣,具体选择取决于你的需求。

ms44的专栏 4027

Codeforces Round 1034 (Div. 3) A-G 题解

文章主要记录了作者参加Codeforces Round 1034 (Div. 3) 的经历与题解分析。作者因D题未及时处理导致未能AK(全部正确),并反思思维题能力不足。随后整理了7道赛题的解题思路与代码。

AKDreamer_HeXY的博客 1563

别再死记硬背了!用LTspice和Simulink仿真,5分钟搞懂巴特沃斯、切比雪夫、贝塞尔滤波器的区别

本文通过LTspice和Simulink仿真工具,直观对比了巴特沃斯、切比雪夫和贝塞尔滤波器的特性差异。从通带波纹、过渡带陡峭度到相位线性度,详细解析了三种经典滤波器的设计哲学与应用场景,帮助工程师和学生快速掌握滤波器选型技巧,提升电路设计效率。

weixin_33910191的博客 523

十年芯片资深IC设计工程师面经系列(四)SDC约束

set_driving_cell:当我们的设计是模块级(Block level)的design时,我们的设计前面一般还有其他的设计,那么前面模块的输出便是我们模块的输入,5.1set_false_path:可以单独的时钟或者路径进行约束。set drive :当我们的设计是芯片级(Chip level)的顶层设计时,芯片外围电路要驱动的是负载较大的IO单元,故需要的驱动能力较强,:set_load 是指output端口的负载,设置的值会影响输出到端口的net上的电容,从而影响相应的路径延时。

weixin_47349046的博客 1773

codeforces round 1034(div. 3)

只有当a[i]是某个前缀的最小值或者某个后缀的最大值时才可以通过一系列操作将数组转换为 a[i​],对应的输出1,否则输出0。

2402_87610050的博客 796

硬件工程师的破局之路:为何你才是考取软考高级架构师的“天选之子”?

硬件工程师如何转型系统架构师:独特优势与实战路径 文章揭示了硬件工程师在考取系统架构设计师证书时的独特优势。作者指出,硬件工程师的全局思维、接口设计能力和可靠性经验正是系统架构的核心要素。通过将硬件经验升维为架构思维(从引脚到接口、从单板到系统、从实现到权衡),硬件背景反而成为竞争优势。文章建议通过知识补全、建立架构决策日志和术语转换练习来备考,并强调硬件工程师在软硬协同时代的独特价值——既能统领硬件设计,又能为软件搭建最佳舞台。文末鼓励硬件工程师以更高视野看待职业发展,将系统架构师认证视为水到渠成的职业升

云轩阁 532

Codeforces Round 1034 (Div. 3)补题

之间的素数,一定是不动点。除去这些素数,我们对每一个奇数(非素数)进行下面操作。本人对该题原理的理解不是很清晰,觉得学习群论或数论对本题会有帮助。在Bob操作的时候,左边有。我们将问题转换成其对偶问题,将删除操作改为选择操作,删除。的倍数,赢家是Bob,否则赢家是Alice.对于剩下的偶数,我们只需要进行循环位移就行。按照这样的贪心策略,得到的。值取到最小值,根据贪心的规则,通过。时,可以通过操作得到最后的结果。的最小因子,且必为素数。对于剩下的奇数,我们对于每一个。),根据容斥原理,当满足。

2301_80198205的博客 718

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Codeforces Round 1034 (Div. 3) G 题解

题目要求维护一个数组,支持修改元素和查询操作。查询时需要判断是否存在通过多次加k取模m的操作使数组单调不减。解法基于裴蜀定理,预处理每个元素对所有m的因数取模的结果,并统计需要调整的次数。修改时更新预处理数据,查询时检查处理后数组是否满足条件。时间复杂度为O(√m + n√m + q√m)。

AKDreamer_HeXY的博客 1103

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Codeforces Round 1034 (Div. 3)题解

思路:我们可以对其分情况考虑,我们对k和n的关系去讨论,我们考虑什么时候才能让这个字符串里面的1的个数减少,我们们会发现,当k>=n/2+1的时候,1的个数会在每次操作后-1,直到变成k个,然后全部变成0,这个时候就要输出Alice了,另外一种情况是k<=n/2,这种情况,只有在1的个数小于等于k的时候才能输出Alice,否则就是输出Bob了。在来分析如果右边没有比他大的,但是左边有比他小的,直接后缀跑一遍就可以了,如果右边没有比他大的,但是左边有比他大的,可以先前缀跑一遍,然后在后缀更新成当前值。

2301_80475191的博客 638

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Codeforces Round 1034 (Div. 3) F 题解

题目要求构造一个排列,满足每个位置i(i≥2)的gcd(p_i,i)>1,同时最小化不动点(p_i=i)的数量。 解法思路: 1必须放在第一位,否则不满足gcd条件 对于大于n/2的质数k,p_k必须等于k 对于其他质数k,将其倍数按环状排列(如3→6→9→12→3) 未被处理的偶数2单独处理 时间复杂度O(n log n),使用埃式筛预处理素数。代码实现了上述思路,通过循环处理每个质数的倍数,构造满足条件的排列。

AKDreamer_HeXY的博客 836

Codeforces Round 1034 (Div. 3) A-F

给你一个0~n-1的数组,两个玩家alice和bob在一回合中alice可以随便选择一个数a并删掉bob只能选择一个数b满足(a+b)%4=3当一个玩家不能删掉数的时候这个玩家输掉游戏问在不同n的情况下,谁最后能赢得游戏。

qq_34832548的博客 1035

Codeforces Round 1034 E题题解 (Div.3)

思维题,数据结构。

2401_86718044的博客 895

Codeforces Round 1034 (Div. 3)(A,B,C,D,E,F)

当删除元素大于冗余个数时,我们发现必须要对一个去重后的数组进行操作,具体的,假设现在为0,1,2,3,4,5要删除一个元素,很显然mex最多有6种取值(0,1,2,3,4,5),如果要删除两个元素,最多mex有5种取值(0,1,2,3,4)…思路:考虑直接模拟发现,如果n刚好是4的倍数,那么A每次随便拿一个数B都至少有一个数可以选,直到最后所有数被选完,A没有数可以选所以A输B赢,反之B在最后无法选择和A选的数匹配的数(假设当前剩下[0,1,2],A选0以后B没有对应的数可以选,所以B输A赢)

2301_80064362的博客 1114

Codeforces Round 1034 (Div. 3) G解题思路

对样例进行分析可以发现对于每个a[i]可以分为g=gcd(m,k)类,可以为每一类标号,号码为a[i]%g,例如样例一中面对2 4,k=4,m=6,gcd(m,k)=2,数组中4,2,2,4,0可以分成一类,号码为0,这些数字经过多次操作可以变成0,2,4中的任意一个。0 1/0 0 0 1/0,第1组的0,1对应两类中的第一个数0,1,第2组的0 0 0 1对应两类中的第二个数 2 2 2 3,第三组的0对应两类中的第三个数4,即最终构造了0 1 2 2 2 3 4。1.令a[i]=x(永久性)

2301_80281361的博客 531

Codeforces Round 1034 (Div. 3) vp补题复盘A-D

菜

头顶尖尖的博客 692

Codeforces Round 1034 (Div. 3) G题题解记录

其可能会影响的只有左边和右边两个数。所以只需要判断修改前后大小关系,更新。所以,对于是否可以组成非递减序列,我们只需要判断跳跃次数。,使得得到的新的数组呈现非递减排列(不实际改变,只询问)。以此类推,根据跳跃次数,在跳跃次数相同的时候,如果。的大小关系来判断,更新的时候更新所有因数。从0次跳跃开始,最多可以跳跃多少次?,那么在先前保证贪心策略下,:查询:是否能够针对每一个。大致题意:给定一个正整数。必须进行一次跳跃才能保证。我们预处理出所有可能作为。所有可以变化的数为一个。可以变化的最小的数就是。

m0_55592958的博客 739
上一篇: 前端框架前置-相关知识学习
下一篇: 牛客周赛 Round 98
一只鱼^_
博客等级 码龄3年 1073粉丝 92原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值