题意:有一个长度为\(n\)的序列,可以操作\(3\)次,每次选取一段区间,然后区间的元素加减区间长度的倍数,\(3\)次操作后使得序列所有元素为\(0\),问具体操作情况. 题解:假如我们能选择一整段区间\([1,n]\),使其所有元素都是\(n\)的倍数就好了,但是有的元素不是\(n\)的倍数,所以不能这样搞,但是我们可以选择\([2,n]\),这样区间长度就变成了\(n-1\),于是不管元素是不是\(n\)的倍数,\(n-1\)的倍数总能将其抵消使其成为\(n\)的倍数,接下来模拟搞一搞就…
题意:给你一个由\(0,1,?\)组成的字符串,你可以将\(?\)任意改成\(0\)或\(1\),问你操作后能否使得该字符串的任意长度为\(k\)的区间中的\(0\)和$1的个数相等. 题解:我们首先看前\(k\)个字符,那么对于区间\([2,k+1]\),如果要满足条件,\(s_{k+1}=s_{1}\)一定要成立,由此我们可以推导出,\(s_{i\ mod\ k}=s_{i}\),然后模拟就可以了,具体看代码. 代码: int t; int n,k; char s[N]; int cnt1,…
题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数)为k个.求序列. 思路:1~k+1.构造序列前段,之后直接输出剩下的数.前面的构造能够依据,两项差的绝对值为1~k构造. AC代码: #include <stdio.h> #include <string.h> int ans[200010]; bool vis[100010]; i…
题目链接:Power Sequence 题意: 给你n个数vi,你可以对这个序列进行两种操作 1.可以改变其中任意个vi的位置,无成本 2.可以对vi进行加1或减1,每次操作成本为1 如果操作之后的vi(设v数组下标从1到n)满足:如果存在一个数c,使得每一个vi都满足vi==ci 你需要输出这个满足题意得vi数组构成所需的最小成本 题解: 题目要求1<=ai<1e9,那么可以说所有vi都加起来得数量级是1e9,那么也就说如果cn,那么c这个数就不可取 因为我们c可以取1,那么成本最大也是在1…
比赛链接:https://codeforces.com/contest/1397 A. Juggling Letters 题意 给出 $n$ 个字符串,可在字符串间任意移动字母,问最终能否使这 $n$ 个字符串相同. 题解 如果可以,因为 $n$ 个字符串相同,所以每个字母的数量一定是 $n$ 的倍数. 代码 #include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<…
题意:有一个长度为\(n\)的序列,你每次可以对序列重新排序,然后花费\(1\)使某个元素加减\(1\),多次操作后使得新序列满足\(a_{i}=c^i\),\(c\)是某个正整数,求最小花费. 题解:先排序,我们可以直接枚举\(c\),然后模拟维护一个最小值就好了. 代码: int n; int a[N]; int main() { //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); n=read(); for(int i=1;i<=n;…
题目链接:http://codeforces.com/problemset/problem/719/C C. Efim and Strange Grade time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Efim just received his grade for the last test. He studies in a…
C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction as a sum of three distinct posit…
A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. Alyona is a capricious girl so after she gets the array, she…
B. War of the Corporations 题目连接: http://www.codeforces.com/contest/625/problem/B Description A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the…