题目链接 题目大意 有n个维度为m的向量,取其中两个进行合并,合并时每个维度取两者之间的较大者,得到的新的向量中,维度值最小者最大为多少 分析 首先最需要注意的是m的取值,m最大只有8 那么我们可以二分答案,对于每一个二分值,进行下面的操作 将整个矩阵的每一个元素,如果这个元素大于二分值,则变成1,反正则变成0 把每一个向量压缩为单个二进制数 这样我们最多只会得到\(2^8 = 256\)种不同的二进制数,然后暴力的遍历所有可能的二进制数的组合,得到是否满足当前二分值 AC code #incl…
D. Minimax Problem time limit per test 5 seconds memory limit per test 512 megabytes input standard input output standard output You are given nn arrays a1a1, a2a2, ..., anan; each array consists of exactly mm integers. We denote the yy-th element of…
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://codeforces.com/contest/985/problem/F Description You are given a string s of length n consisting of lowercase English letters. For two given strings s an…
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w…
You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist. Divisor of n is any such natural number, that n can be divided by it without remainder. Input The first line contains two integers n and k (1 ≤ n ≤ …
题目链接:http://codeforces.com/problemset/problem/616/A 题目意思:顾名思义,就是比较两个长度不超过 1e6 的字符串的大小 模拟即可.提供两个版本,数组版本 & 指针版本. (1)数组版本(短的字符串从高位处补0,直到跟长的字符串长度相同) #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using…
题目链接:http://codeforces.com/contest/710/problem/E 题意:开始文本为空,可以选择话费时间x输入或删除一个字符,也可以选择复制并粘贴一串字符(即长度变为两倍),问要获得长度为n的串所需最少的时间. 思路:dp[i]表示获得长度为i的串所需要的最短时间,分i为奇数和偶数讨论. #include<bits/stdc++.h> using namespace std; const int N=1e7+3; typedef long long ll; ll…
E. Analysis of Pathes in Functional Graph time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output You are given a functional graph. It is a directed graph, in which from each vertex goes exactly o…
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d ki…
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line…
E. Sum of Remainders 题目连接: http://www.codeforces.com/contest/616/problem/E Description The only line contains two integers n, m (1 ≤ n, m ≤ 1013) - the parameters of the sum. input The only line contains two integers n, m (1 ≤ n, m ≤ 1013) - the para…
D. Longest k-Good Segment 题目连接: http://www.codeforces.com/contest/616/problem/D Description The array a with n integers is given. Let's call the sequence of one or more consecutive elements in a segment. Also let's call the segment k-good if it conta…
C. The Labyrinth 题目连接: http://www.codeforces.com/contest/616/problem/C Description You are given a rectangular field of n × m cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are…
B. Dinner with Emma 题目连接: http://www.codeforces.com/contest/616/problem/A Description Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefer…
A. Comparing Two Long Integers 题目连接: http://www.codeforces.com/contest/616/problem/A Description You are given two very long integers a, b (leading zeroes are allowed). You should check what number a or b is greater or determine that they are equal.…
E. Minimum spanning tree for each edge 题目连接: http://www.codeforces.com/contest/609/problem/E Description Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) f…
D. Gadgets for dollars and pounds 题目连接: http://www.codeforces.com/contest/609/problem/C Description Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for som…
C. Load Balancing 题目连接: http://www.codeforces.com/contest/609/problem/C Description In the school computer room there are n servers which are responsible for processing several computing tasks. You know the number of scheduled tasks for each server:…
B. The Best Gift 题目连接: http://www.codeforces.com/contest/609/problem/B Description Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale…
A. USB Flash Drives 题目连接: http://www.codeforces.com/contest/609/problem/A Description Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a1, a2, ..., an megabytes. The file size is equal to m…
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the gi…
http://codeforces.com/problemset/problem/1073/D 题目大意:有n个物品(n<2e5)围成一个圈,你有t(t<1e18)元,每次经过物品i,如果身上的钱可以购买该物品就直接购买,直到一件物品都不能购买,求一共可以购买多少件物品. 题目分析:由于t的数量级达到了1e18,所以不可能直接进行暴力模拟,这个时候就要想到周期性地模拟. 题解:每次遍历一下1~n这n个物品,然后计算出可以取的物品数以及价值,然后用剩下的钱除以这个价值,得到可以进行的轮数,累加到…
题目链接:http://codeforces.com/contest/616/problem/E 题目大意:给定整数n,m(1≤n,m≤1013), 求(n mod 1 + n mod 2 + ... + n mod m)的值(mod Pt = 1e9 + 7). 思路:这题一看是看觉得题意简洁,通过人数不多一定是一道用到各种定理的碉堡数论题.后来仔细想了一下发现是乱搞… 首先通过观察数据范围,结合数论题的复杂度传统考虑O(√n)算法. 把n拆解,可以任意写成很多种n = px + r 的形式,…
E. Minimum spanning tree for each edge 题目连接: http://www.codeforces.com/contest/609/problem/E Description Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) f…
题目链接:http://codeforces.com/contest/818 A. Diplomas and Certificates 题解:水题 #include <iostream> #include <cstring> #include <cmath> using namespace std; typedef long long ll; int main() { ll n , k; cin >> n >> k; ll gg = n / 2;…
题目链接:https://codeforc.es/contest/1076 A. Minimizing the String 题意:给出一个字符串,最多删掉一个字母,输出操作后字典序最小的字符串. 题解:若存在一个位置 i 满足 a[i] > a[i+1],若不删除 a[i] 则后续操作不可能更优. #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long lo…
传送门 Div 2的比赛,前四题还有那么多人过,应该是SB题,就不讲了. 这场比赛一堆计数题,很舒服.(虽然我没打) E. The Top Scorer 其实这题也不难,不知道为什么这么少人过. 考虑枚举那人的分数和有多少人和他同分,推一下就会发现我们只需要知道\(calc(sum,n,top)\)表示\(sum\)分,分给\(n\)个人,分数小于\(top\),的方案数. 好像不是很好直接搞,考虑容斥,枚举一下至少有几个人不满足条件即可. #include<bits/stdc++.h> na…
E - Thief in a Shop 题目大意:给你n ( n <= 1000)个物品每个物品的价值为ai (ai <= 1000),你只能恰好取k个物品,问你能组成哪些价值. 思路:我们很容易能够想到dp[ i ][ j ]表示取i次j是否存在,但是复杂度1e12肯定不行. 我们将ai排序,每个值都减去a[1]然后再用dp[ i ]表示到达i这个值最少需要取几次,只需要1e9就能完成, 我们扫一遍dp数组,如果dp[ i ]  <= k 则说明 i + k * a[1]是能取到的.…
D. Timetable time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ivan is a student at Berland State University (BSU). There are n days in Berland week, and each of these days Ivan might have s…
Water The Garden #pragma comment(linker, "/STACK:102400000,102400000") #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector> #include<algorithm> #include<iostream> #include<map> #inclu…