https://vjudge.net/problem/CodeForces-768C 题意:n个数,k次操作,x.每次操作先排序,再让奇数位置上的数据a[i]:=a[i] XOR x;   k<1e5,x<1e5,a[i]<1e3. 题解:由于每个数据为1~1000,且每次操作先排序,所以可以用桶排序维护所有数据.然后模拟操作(我自己模拟的一直wa,换了另一种才ac). 网上另外也有人k%=64 然后暴力ac了,还有找循环节的也ac 了. 坑:第一次看codeforce 的数据,结果ou…
题意: 给出一个数列,和一种操作,以及两个数x和k. 这个操作有两个步骤: 首先把这个数列按照升序排序,然后把所有奇数位上的数字与x异或. 问执行k次操作之后,这个数列的最大值和最小值是多少. 思路: 由于每个数字异或两次之后会变回本身,所以猜测这个数列有可能会循环,所以就可以暴力计算周期,对于每一次出现的数列,看看是否与前面某次出现过的数列相同,这是暴力的思路.玄学复杂度. 更优雅的思路: 发现a[i]的最大值为1000,任意1000以内的两个数字异或不会超过1023,所以可以统计0到1023…
地址:http://codeforces.com/contest/768/problem/C 题目: C. Jon Snow and his Favourite Number time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Jon Snow now has to fight with White Walkers. He has…
C. Jon Snow and his Favourite Number time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Als…
[题目链接]:http://codeforces.com/contest/768/problem/C [题意] 给你n个数字; 让你每次把这n个数字排序; 然后对奇数位的数字进行异或操作,然后对新生成的序列再重复上述操作总共k次; 问最后的序列的最小值和最大值分别是多少; [题解] 可以用计数排序来搞; 因为数字最大为1000; 所以将近O(K*1000)的复杂度; 完全可以的; 每次从小到大(0到1000(枚举数字; 然后根据该数字的个数判断该数字有几个数字要进行异或,几个数字保持原样. 然后…
链接 题意 给定数组, 每次操作先将数组排序, 再将奇数位全部异或x, 求k次操作后数组最大值与最小值 (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) 题解 直接暴力模拟是O(nk)的, 注意到元素范围均较小可以用桶达到O(1024*k) 该题k过大时会好像一定出现循环, 然后暴力模拟几次也能过, 没看出来怎么证明... #include <iostream>#include <cstdio> #include <algorithm> #…
题目链接:http://codeforces.com/contest/768/problem/C 题意:给出n个数,k个操作,和一个x,每次操作先排序然后对奇数位数进行xor x操作,最后问k次操作后最大值和最小值 为多少. 题解:看似是要找规律的但是只要暴力就行了.主要是a[i]的范围就只有10的3次,而且时间还有4s,直接来一个vis[i]表示 0-2048个数内取了几个,这样排序都不用了.直接for 0-2048就行.(2的10次1024,异或2的9次就是,2的11次减1 所以设最大为20…
发现值域很小,而且怎么异或都不会超过1023……然后可以使用类似基数排序的思想,每次扫一遍就行了. 复杂度O(k*1024). #include<cstdio> #include<cstring> using namespace std; int n,k,x,cnts[1110],tmpcnts[1110]; int main() { // freopen("c.in","r",stdin); int X; scanf("%d%d%…
http://codeforces.com/contest/768/problem/C 这题的数值大小只有1000,那么可以联想到,用数值做数组的下标,就是类似于计数排序那样子.. 这样就可以枚举k次操作,然后for (int i = 0; i <= 1025; ++i),也就是O(1000 * k)的复杂度而已. 0--1000中任选两个数异或,最大值是1023 然后注意下只有奇数位异或,dp[now][val]计数转移下去就好了 #include <cstdio> #include…
题目描述: C. Producing Snow time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of i…
引子: A题过于简单导致不敢提交,拖拖拉拉10多分钟还是决定交,太冲动交错了CE一发,我就知道又要错过一次涨分的机会.... B题还是过了,根据题意目测数组大小开1e5,居然蒙对,感觉用vector更好一点... C题WA第9组,GG思密达....明天起床再补C吧 - - 题目链接: http://codeforces.com/contest/835/problem/B B. The number on the board Some natural number was written on t…
链接: https://codeforces.com/contest/1215/problem/B 题意: You are given a sequence a1,a2,-,an consisting of n non-zero integers (i.e. ai≠0). You have to calculate two following values: the number of pairs of indices (l,r) (l≤r) such that al⋅al+1-ar−1⋅ar…
D. Minimum number of steps time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of s…
题目链接:http://codeforces.com/problemset/problem/768/D 令$f[i][j]$表示当前产生过了$i$个球,产生过了$j$个不同的球的概率. ${Ans_i=Min\left \{ x|f[x][k]>\frac{p_i-\varepsilon }{2000} \right \}}$ 考虑转移: ${f[i][j]=\frac{j}{k}*f[i-1][j]+\frac{k-j+1}{k}*f[i-1][j-1]}$ ${f[0][0]=1}$ 可能答…
题目链接:http://codeforces.com/contest/948/problem/C 题目大意:给定长度n(n<=1e5),第一行v[i]表示表示第i堆雪的体积,第二行t[i]表示第1~i天的雪将要消融的体积,一堆雪如果消融到体积为0则消失,求每天消融的雪的体积. 解题思路:用优先队列,第i天就将v[i]+sum[i-1]放入优先队列中,然后初始消融量ans=t[i]*q.size(),假设每堆雪都够消融,然后根据优先队列找到q.top()<=sum[i]即不够消融的,减掉差值.…
E - Bus Number 最近感觉打CF各种车祸.....感觉要反思一下, 上次读错题,这次想当然地以为18!肯定暴了longlong 而没有去实践, 这个题我看到就感觉是枚举每个数字的个数,但是我觉得算得时候会爆longlong 就想用大数,但是我去看别人交的全部都是C++,就感觉是不是有别的方法, 想了半天感觉时间来不及了就强行上了个java,结果时间来不及... 以后写题首先要读清楚题目,其次不要想当然,要去实践!!!!!!!!!!! 真的很烦. import java.math.Bi…
B. Perfect Number time limit per test2 seconds memory limit per test256 megabytes Problem Description We consider a positive integer perfect, if and only if the sum of its digits is exactly 10. Given a positive integer k, your task is to find the k-t…
传送门 题意 给出n个数及x,求 \[\frac{\sum _{i=1}^n x^{a_1+a_2+...+a_{i-1}+a_{i+1}+...a_n}}{\prod_{i=1}^n x^{a_i}}\] 分析 结果必然为\(x^{sum}\),sum的值首先取所有数的和减去最大值 然后暴力合并,具体原因我不太懂,只能附上CF的标准题解 Obviously, the answer is \(x^v\). Let \(sum = a1 + a2 + ... + an\). Also let $s…
链接: https://codeforces.com/contest/1271/problem/E 题意: At first, let's define function f(x) as follows: f(x)={x2x−1if x is evenotherwise We can see that if we choose some value v and will apply function f to it, then apply f to f(v), and so on, we'll…
题目传送门 B. Perfect Number time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output We consider a positive integer perfect, if and only if the sum of its digits is exactly 1010. Given a positive integ…
B. Long Number time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a long decimal number aa consisting of nn digits from 11 to 99. You also have a function ff that maps every dig…
#include <iostream> #include <vector> using namespace std; int main(){ ; cin >> n >>k; ; i < n ; ++ i ){ int a; vector<,); cin >> a; while(a){ <=k) goodNum[a%]++; a/=; } ; ; j < k+; ++ j) if(!goodNum[j]) break; )…
传送门 维护一个堆. 每次先算出一个都不弹掉的总贡献. 然后把要弹掉的弹掉,并减去它们对应的贡献. 代码: #include<bits/stdc++.h> #define ri register int using namespace std; typedef long long ll; inline ll read(){ ll ans=0; char ch=getchar(); while(!isdigit(ch))ch=getchar(); while(isdigit(ch))ans=(a…
题目大意:给你n个点的一棵树, 每个点的权值为2^i ,让你删掉k个点使得剩下的权值和最大. 思路:这题还是比较好想的, 我们反过来考虑, 剩下一个的情况肯定是选第n个点,剩下两个 我们肯定优先考虑第n - 1 个点, 因为其他点全部加起来都没有这个点的权值大, 所以我们可以 以第n个点为根, 倍增出每个点祖先的情况, 然后从后往前贪心, 能取到就取, 不能取到就跳过. #include<bits/stdc++.h> #define LL long long #define fi first…
最后肯定是bbbb...aaaa...这样. 你每进行一系列替换操作,相当于把一个a移动到右侧. 会增加一些b的数量……然后你统计一下就行.式子很简单. 喵喵喵,我分段统计的,用了等比数列……感觉智障.一个a一个a地统计答案即可. #include<cstdio> #include<cstring> #include<iostream> using namespace std; #define MOD 1000000007ll typedef long long ll;…
题意: n天. 每天你会堆一堆雪,体积为 v[i].每天都有一个温度 t[i] 所有之前堆过的雪在第 i 天体积都会减少 t[i] . 输出每天融化了的雪的体积. 这个题的正解我怎么想都很难理解,但是慢慢理解了. 计算一个 t[i] 的前缀和 sum. 那么到第 j 天时,设第 i 堆雪融化的体积是 V,则 V = min (sum [ j ] - sum[ i-1], v[ i ] ) 所以把 v[ i ] + sum[ i -1] 加入优先队列里,就可以只处理所有当天能化完的雪了. 若 su…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 看了下样例解释就懂了... 每次选择最大最小的两个组合 然后加起来.. [代码] import java.io.IOException; import java.util.Arrays; import java.util.Scanner; public class Main { static int n; static int a[]; static long sqr(long x) { return x*x; } public stat…
题意:对于一个数\(x\),有函数\(f(x)\),如果它是偶数,则\(x/=2\),否则\(x-=1\),不断重复这个过程,直到\(x-1\),我们记\(x\)到\(1\)的这个过程为\(path(x)\),它表示这个过程中所有\(x\)的值,现在给你一个数\(n\)和\(k\),要你找出最大的数\(x\),并且\(x\)在\(path[1,n]\)中出现的次数不小于\(k\). 题解:我们对于\(x\)可以选择分奇偶来讨论. 1.假如\(x\)为奇数,那么根据题意,我们知道\(x,2x,2x…
C题卡了好久,A掉C题之后看到自己已经排在好后面说实话有点绝望,最后又过了两题,总算稳住了. AC:ABCDE Rank:191 Rating:2156+37->2193 A.Oath of the Night's Watch 题目大意:给定N个数,求有多少个数存在严格比它大的数和严格比它小的数.(N<=100,000) 思路:阅读能力训练+手速,排序一遍就没了. #include<cstdio> #include<cstring> #include<algori…