Codeforce 493c】的更多相关文章

H - Vasya and Basketball Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 493C Description Vasya follows a basketball game and marks the distances from which each team makes a throw. He k…
Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is a lamp in a block, it will light it’s block and the direct adjacent blocks. For example, if there is a lamp at block 3, it will light the blocks 2, 3…
e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头一小改就过了! 只能呵呵...C题还是看了下,又没写,也许写不出吧...的确时候还是看了别人的额,自己写只到第8组WA! 希望下次少,一点! 哎,等我不,b了这个世界也许都不同了!…
又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数(n<=200). 首先很明显可能是区间dp,我们可以记f[i][j]为从i到j的这个多边形的三角剖分数,那么f[i][j]=f[i][k]*f[j][k]*(i,j,k是否为1个合格的三角形) Code: #include<cstdio> #include<iostream> #…
codeforce 375_2 标签: 水题 好久没有打代码,竟然一场比赛两次卡在边界条件上....跪 b.题意很简单...纯模拟就可以了,开始忘记了当字符串结束的时候也要更新两个值,所以就错了 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N = 300; char a[N]; int main() { int n; int l; int su…
codeforce 367dev2_c dp 标签: dp 题意: 你可以通过反转任意字符串,使得所给的所有字符串排列顺序为字典序,每次反转都有一定的代价,问你最小的代价 题解:水水的dp...仔细想想就有了,一个位置要么反转要么就不反转...保证在满足条件时候转移 扔个代码: #include<cstdio> #include<cstring> #include<string> #include<iostream> #include<algorith…
三维dp&codeforce 369_2_C 标签: dp codeforce 369_2_C 题意: 一排树,初始的时候有的有颜色,有的没有颜色,现在给没有颜色的树染色,给出n课树,用m种燃料涂,将相邻相同颜色的树划为一组,最后使得组数为k,并且所用燃料的量最小,给出了每棵树涂j种燃料的用量,如果存在这种涂法输出最小用量,不存在输出-1: 题解: 很容易看出是一个三维dp, dp[i][j][k] 表示处理到第i棵树,最后一棵树为颜色j,现在已经分成的组数为k的时候的最小用量 转移方程如果当前…
强连通分量 标签: 图论 算法介绍 还记得割点割边算法吗.回顾一下,tarjan算法,dfs过程中记录当前点的时间戳,并通过它的子节点的low值更新它的low,low值是这个点不通过它的父亲节点最远可以到达的dfn值最小的点,如果当前的节点的low>他父亲节点的dfn说明它不能通过其他的边到达它的父亲,那么它和他父亲的这条边就是割边,在这个算法中有三个标号,VIS数组,标记为0表示没有被访问到,标记为1表示这个点正在搜索它的自孩子,标记为2表示这个点已经处理过了,就是已经找到了它属于哪个联通块,…
[树状数组]区间出现偶数次数的异或和(区间不同数的异或和)@ codeforce 703 D PROBLEM 题目描述 初始给定n个卡片拍成一排,其中第i个卡片上的数为x[i]. 有q个询问,每次询问给定L和R表示,询问的区间[L,R]内的卡片所有出现了偶数次的数的异或和是多少. 输入 输入一行两个整数n,q. 第二行n个整数,第i个数为x[i]. 接下来q行,每行两个整数L和R,表示询问的区间. 输出 输出q行,其中第i行表示第i次询问的区间出现偶数次的数的异或和. 样例输入 3 1 3 7…
codeforce 7C C. Line time limit per test1 second memory limit per test256 megabytes A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·101…
An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic progressi…
You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m. Input The first line contains two numbers, n and m…
In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of th…
Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player…
To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the se…
Prime Number CodeForces - 359C Simon has a prime number x and an array of non-negative integers a1, a2, ..., an. Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and…
A tournament is a directed graph without self-loops in which every pair of vertexes is connected by exactly one directed edge. That is, for any two vertexes u and v (u ≠ v) exists either an edge going from u to v, or an edge from v to u. You are give…
CodeForce 855B 暴力or线段树 题意 给你一串数,然后找出三个数,他们的前后关系和原来一样,可以相同,然后分别乘p,q,r,求他们积的和最大,并且输出这个数. 解题思路 这个可以使用线段树来做,找出区间内的最小值和最大值,如果x(代表pqr中的一个)小于零,就乘以这个区间的最小值,如果大于零,就乘以这个区间的最大值.然后\(j\)从1到n开始遍历. 或者可以暴力,不过这个暴力比一点重方法还要好,我看完就惊呆了,lxm大佬太强了. 代码实现 第一种: #include<cstdio>…
新鲜热乎的题 Codeforce 1175 D. 题意:给出一个长度为$n$的序列$a$,你需要把它划分为$k$段,每一个元素都需要刚好在其中一段中.分好之后,要计算$\sum_{i=1}^{n} (a_i \centerdot f(i))$,使这个值最大.其中$f(i)$代表第$i$个元素被分在第几段中.简单来说,就是每个元素被分在第几段中就需要乘上几,使序列的和最大. 假设$sum$是$a$的前缀和,$k$个分割点分别为$l_j$,将序列分割为$[1, l_1],[l_1 + 1, l_2]…
You want to perform the combo on your opponent in one popular fighting game. The combo is the string s consisting of n lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in s. I.e. if s="abca" t…
codeforce Round #643 #645 #646 div2 Round #643 problem A #include<bits/stdc++.h> using namespace std; #define ll long long ll findmin(ll x){ ll minn=99; while(x!=0){ if(x%10<minn) minn=x%10; x/=10; } return minn; } ll findmax(ll x){ ll maxx=-1; w…
10^4以内只由4和7构成的数字只有31种,那么做法就很简单了,求出每个数字与其最接近的幸运数的差值,然后建立线段树,线段树维护区间最小值和最小值个数,如果操作过程中最小值<0,那么就去对差值进行暴力修改,直到区间差值>=0,很明显线段树每个叶子节点不会被修改超过31次,询问操作的话差值=0的数字就是幸运数了.复杂度O(31nlogn) 代码 #include <algorithm> #include <iostream> #include <sstream>…
题目链接:http://codeforces.com/problemset/problem/730/J 题目大意:有n个杯子, 每个杯子有两个值一个是已装水量,一个是可装水量.从一个杯子向另一个杯子倒1单位体积的水,时间花费为1s. 现在用n个杯子中的s个来装所有水, 求最小的s, 以及最少花费的时间. 解题思路:有了n杯水的总水量, 可以按照n个杯子的大小排序, 然后就可以求出最小的s.然后就可以将题目看做是求从n个杯子里面选s个,这s个杯子的总的可装水量是大于等于总水量,这种情况下这n个杯子…
/* 题意:n个同学,k个车, 取旅游d天! 要求所有的学生没有两个或者两个以上的在同一辆车上共同带d天! 输出可行的方案! 对于d行n列的矩阵,第i行第j列表示的是第i天第j个同学所在的车号! 也就是保证所有行不全相同,即每一列都是不相同的! 如果每一列都不相同就是表示第j个同学(第j列)在这d天中不会和其他同学(列)在这d天中 都在同一辆车中! 思路:对于每一列我们枚举d天该学生所在的车号!它的下一列只保证有一个元素和它不同就行了!依次下去! 还有一共有 d 个位置来填充车号(1....k)…
Untitled Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 947    Accepted Submission(s): 538 Problem Description There is an integer a and n integers b1,…,bn. After selecting some numbers from b1…
B. Island Puzzle time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A remote island chain contains n islands, labeled 1 through n. Bidirectional bridges connect the islands to form a simple c…
题目链接:http://codeforces.com/contest/507/problem/C 解题报告:现在有一个满二叉树型的迷宫,入口在根结点,出口在第n个叶节点,有一串命令,LRLRLRLRLR.....,L表示当前向左走,R表示现在向右走,然后如果碰到如果下一步的点是已经走过的,则跳过这条命令,如果下两步都是走过的话,则回到该节点的父节点.问从根结点走到出口一共到过多少个节点,包括出口节点,不包括根结点. 这是一棵满二叉树,现在假设出口的E那个点,从1出发,向左走,很显然,出口跟我现在…
Codeforces Round #318 居然可以看测试数据,哪里没过一目了然,哈哈哈 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<map> using namespace std; #define MOD 1000000007 cons…
B2. Shave Beaver!   The Smart Beaver has recently designed and built an innovative nanotechnologic all-purpose beaver mass shaving machine, "Beavershave 5000". Beavershave 5000 can shave beavers by families! How does it work? Very easily! There…
Soldier and Number Game Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 546D Description Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and…