CodeForces 448】的更多相关文章

A:Rewards: 题目链接:http://codeforces.com/problemset/problem/448/A 题意:Bizon有a1个一等奖奖杯,a2个二等奖奖杯,a3个三等奖奖杯,b1个一等奖奖牌,b2个二等奖奖牌,b3个三等奖奖牌,和一个有n个架子的橱柜.如今Bizon想把这些奖牌和奖杯放在橱柜里,可是要遵循以下的规则:一个架子上不能同一时候放奖杯和奖牌:一个架子上的奖杯数量不能超过5个.奖牌数量不能超过10个. 问能不能把这些奖杯和奖牌所有放进去. 分析:依照贪心原则.一个…
#448 Div2 E 题意 给出一个数组,有两种类型操作: 选定不相交的两个区间,分别随机挑选一个数,交换位置. 查询区间和的期望. 分析 线段树区间更新区间求和. 既然是涉及到两个区间,那么对于第一个区间而言,它的和的期望由两部分组成:它剩下的数的和的期望,从第二个区间换过来的数的和的期望.第二个区间同理. 可以用两个数组分别(间接)维护这两部分的值(类似于线段树中常见的 lazy 数组). code #include<bits/stdc++.h> using namespace std;…
二分法判断答案 D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the multiplicat…
题目链接:E. Divisors 题意: 给出一个X,f(X)是X所有约数的数列(例6:1 2 3 6),给出一个k,k是递归的次数(例:k=2 : f(f(X)) ; X=4,k=2: 1 1 2 1 2 4 ), X (1 ≤ X ≤ 10^12) and k (0 ≤ k ≤ 10^18).现在给出X与k让你求这个序列,序列长度如果超过1e5就只存1e5个数. 题解: 这个题的话除了DFS没有想到特别好的方法,但是问题是强行DFS时间会超@.@.(DFS思路:处理出dfs时数的所有约数(n…
题目链接:D. Multiplication Table 题意: 给出N×M的乘法矩阵要你求在这个惩罚矩阵中第k个小的元素(1 ≤ n, m ≤ 5·10^5; 1 ≤ k ≤ n·m). 题解: n和m最大都是5e5那矩阵最大就有2e11不能够暴力,其实这里就应该想到要用二分做的,但是我做题的时候脑抽@.@想要推规律,然后就决决了.那么讲一下二分怎么做,就先简单的二分答案在(1-n*m)中二分,然后cheak函数中找所有矩阵中比所给值小的元素,个数大于等于k为成立条件.复杂度(O(n*log(…
递归.分治. . . C. Painting Fence time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Bizon the Champion isn't just attentive, he also is very hardworking. Bizon the Champion decided to paint his ol…
题目链接 Codeforces Round #448 C. Square Subsets 题解 质因数 *质因数 = 平方数,问题转化成求异或方程组解的个数 求出答案就是\(2^{自由元-1}\) ,高消求一下矩阵的秩,完了 或者 由于数很小, 我们只需要对于每个数的质因数装压 对这组数求线性基,n - 线性基中的数就是自由元个数 代码 #include<bits/stdc++.h> using namespace std; inline int read() { int x = 0,f =…
传送门:http://codeforces.com/contest/895/problem/B B. XK Segments time limit per test1 second memory limit per test256 megabytes Problem Description While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the l…
传送门:http://codeforces.com/contest/895/problem/A A. Pizza Separation time limit per test1 second memory limit per test256 megabytes Problem Description Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks…
被B的0的情况从头卡到尾.导致没看C,心情炸裂又掉分了. A. Pizza Separation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the…
题目描述有点小坑,ij其实是没有先后的 并且y并不一定存在于a中 判断y的个数和所给数组无关 对于2 - 7来说 中间满足%2==0的y一共有3个 2 4 6 这样 可以看出对于每个数字a 都能够二分出来一个范围resl resr 这个范围内的数字到a 之间一共有k个x的倍数 然后就是查找一下a数组中有多少数字在resl和resr中间 也是二分寻找 L n,ds,num; L a[100050] ; L fin(L l,L r,L ds) { L num1=r/ds; L num2=l/ds;…
可以用状压dp,也可以用线型基,但是状压dp没看台懂... 线型基的重要性质 性质一:最高位1的位置互不相同 性质二:任意一个可以用这些向量组合出的向量x,组合方式唯一 性质三:线性基的任意一个子集异或和不为0. 详细见:线型基介绍 题意:给一个数组,找相乘起来是完全平方数的所有组数 解法:先打70的素数表,对每一个数的素数因子个数%2之后进行压位,为什么要这样做呢,是因为,相乘之后如果是素数那么一定能分解成偶数个素数因子相乘,那么就可以转化成求亦或起来是0的组数,用线型基处理,对于不在线型基中…
B. XK Segments time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher sug…
A. Pizza Separation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order…
Pizza Serparation #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector> #include<algorithm> #include<iostream> #include<map> #include<queue> using std::vector; using std::queue; using std:…
http://codeforces.com/contest/448/problem/D 题意:一个n×m的矩阵,a[i][j]=i*j; 然后把a数组排序,找出第k个数. 思路:1-n×m二分枚举,然后统计比小于等于x的数的个数与k相比较. #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #define maxn 1000100 #define ll…
http://codeforces.com/contest/448/problem/C 题意:给你n宽度为1,高度为ai的木板,然后用刷子刷颜色,可以横着刷.刷着刷,问最少刷多少次可以全部刷上颜色. 思路:dp[i][j] 表示在第i列以后的木板都已刷完且第j列的木板是横着刷的,最少需要的次数.如果a[i]>=a[j]的情况,比较再竖着刷一次和横着刷哪一个情况次数少. #include <cstdio> #include <iostream> #include <cst…
题目地址:http://codeforces.com/contest/448/problem/D 当时是依照找规律做的,规律倒是找出来了,可是非常麻烦非常麻烦. . 看到前几名的红名爷们3分钟就过了,于是果断放弃了. .赛后才知道是用二分的方法做,知道了二分之后.剩下的就非常easy了..关键在于能不能想到用二分.. 代码例如以下: #include <iostream> #include <stdio.h> #include <string.h> #include &…
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://codeforces.com/contest/448/problem/D -----------------------------------------------------------------------------------------------…
主题链接:http://codeforces.com/contest/448/problem/D 思路:用二分法 code: #include<cstdio> #include<cmath> #include<iostream> using namespace std; __int64 n,m,k; __int64 f(__int64 x) { __int64 res=0; for(__int64 i=1;i<=n;i++) { __int64 minn=min(…
题目链接:http://codeforces.com/contest/448/problem/C 题目大意:n个1* a [ i ] 的木板,把他们立起来,变成每个木板宽为1长为 a [ i ] 的栅栏,现在要给栅栏刷漆,刷子宽1,刷子可以刷任意长,每次只能横着刷或者竖着刷,问最少需要刷几次?解题思路:参考了这里(https://blog.csdn.net/qq_24451605/article/details/48492573)首先我们能够想到,如果横着刷,为了得到最优解,当前刷的位置的下面也…
题目连接:http://codeforces.com/contest/448 A:给你一些奖杯与奖牌让你推断能不能合法的放在给定的架子上.假设能够就是YES否则就是NO. <span style="font-size:18px;">#include <algorithm> #include <iostream> #include <stdlib.h> #include <string.h> #include <ioman…
题目链接:http://codeforces.com/problemset/problem/448/C C. Painting Fence time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Bizon the Champion isn't just attentive, he also is very hardworking. B…
题目链接:http://codeforces.com/problemset/problem/448/C 题意: 有n个木板竖着插成一排栅栏,第i块木板高度为a[i]. 你现在要将栅栏上所有地方刷上油漆. 每次你可以选择竖着刷或横着刷,但必须保证一次刷的地方不能间断. 问你至少要刷几次才能刷满. 题解: 首先有一个贪心结论: 对于当前要刷的一片区域,令minn为这片区域的最小高度. 如果选择横着刷,则至少要将区域底部的minn层刷完. 如图,至少要将下面两层刷完: 然后考虑如何分治: 对于当前的这…
题目链接:http://codeforces.com/problemset/problem/448/C 题意: 给你n个数字,给定m. 问你是否能从中选出若干个数字,使得这些数字之和为m的倍数. 题解: 其实就是要找一些数字,使得之和mod m为0. 开一个vector,存当前已经能够构成的数字之和mod m之后的值. 一开始vector为空,然后枚举n个数字a[i],对于每个数字枚举当前vector中的值v[i],将没有出现过的(a[i]+v[i])%m值加入vector中. 最后判断下vec…
题目链接:http://codeforces.com/problemset/problem/448/B 题目意思:给出两种操作automaton:可以删除字符串中任意一个字符: array:交换字符串中任意两位.运用这两种操作的次数不限定,问如何运用这两种操作(或其中一种,或两种结合都不能够)使得字符串 s 转换成字符串 t 昨晚做的时候,顶住疲倦死撑,过不了pretest 5,我以为是因为这组数据:ttauotdf  auto,当时没想到怎么做,太困了......今日做才发现原来要用到两个指针…
题目链接:http://codeforces.com/contest/448/problem/B ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943/ma…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…