题意:有\(n\)个桩子,\(1\)表示该位置有一个火炉,可以使两边距离为\(r\)的范围照亮,问最少使用多少炉子使得所有范围都被照亮. 题解:贪心,首先我们从\(r\)位置开始向左找,如果找到了就记录这个位置,然后答案+1,然后再从\(2*r-1\)这个位置开始向左找第一个没有标记的火炉,如果没有找到就直接输出\(-1\)结束,否则重复寻找的过程. 代码: int n,r; int a[N]; bool st[N]; int main() { ios::sync_with_stdio(fals…
任意门:http://codeforces.com/contest/1066/problem/B B. Heaters time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vova's house is an array consisting of nn elements (yeah, this is the first probl…
http://codeforces.com/contest/1066/problem/B Vova's house is an array consisting of nn elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The ii-th element of the a…
Codeforces Round #515 (Div. 3) #include<bits/stdc++.h> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<queue> #include<vector> #incl…
题解:对于每个点 i 来说,从 j = i + r - 1 开始往前找,如果找到一个 a [ j ] 是 1 ,那么就把它选上,但是我们需要判断交界处,也就是如果前面选的那个可以让这个点变温暖,就不用再选多余的了.这样就记录一下前一个 last ,要满足 j > last.找到之后,就更新 i 的值,在 i + k 之间的都可以由选的这个点来温暖. #include <iostream> #include <bits/stdc++.h> using namespace std…
题目链接:http://codeforces.com/contest/1066 1066 A. Vova and Train 题意:Vova想坐火车从1点到L点,在路上v的整数倍的点上分布着灯笼,而在路上从l到r处停着别的火车,它挡着Vova的视线使他看不到灯笼.给定L,v,l,r求Vova能看到的灯笼数. 分析:从1到x上所有的灯笼数量为x/v个.则路上所有的灯笼数为L/v个,被挡住的则为 r/v - (l-1)/v 个,相减即为答案. #include<iostream> #include…
A. Mafia Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/348/problem/A Description One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1…
B. Urbanization 题目链接 http://codeforces.com/contest/735/problem/B 题面 Local authorities have heard a lot about combinatorial abilities of Ostap Bender so they decided to ask his help in the question of urbanization. There are n people who plan to move…
题目链接: http://codeforces.com/problemset/problem/268/E E. Playlist time limit per test 1 secondmemory limit per test 256 megabytes 问题描述 Manao's friends often send him new songs. He never listens to them right away. Instead, he compiles them into a play…
B. Sail 题目连接: http://www.codeforces.com/contest/298/problem/B Description The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directio…
A. Purification Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/problem/A Description You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square r…
A. Exams Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/A Description Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera…
B. Passwords 题目连接: http://codeforces.com/contest/721/problem/B Description Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Code…
C. Woodcutters Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/problem/C Description Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately s…
http://codeforces.com/contest/732/problem/D 这题我发现很多人用二分答案,但是是不用的. 我们统计一个数值all表示要准备考试的所有日子和.+m(这些时间用来考试) 那么这个all值就是理想的最小值.然后去前all个数找,贪心地复习最小的科目,然后有的考试的话,就优先考试. 如果经过这all天,复习完了(这个是肯定得),但是只是因为时间分配不好,导致没得考试(数据导致没得考试) 那么就暴力枚举后面的[all + 1, n].有得考试就去考试,刚好考完就直…
链接: https://codeforces.com/contest/1216/problem/B 题意: Recently Vasya decided to improve his pistol shooting skills. Today his coach offered him the following exercise. He placed n cans in a row on a table. Cans are numbered from left to right from 1…
https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价值为s 题解:min(s/n,a)*n+b>=s?YES:NO #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<algorithm>…
题目:Click here 题意:给你n,然后n个数,n个数中可能重复,可能不是1到n中的数.然后你用最少的改变数,让这个序列包含1到n所有数,并输出最后的序列. 分析:贪心. #include <bits/stdc++.h> using namespace std; ; int n; int a[M]; // 给定序列 int mark[M]; // mark[i] 表示i在给定序列中的出现次数 int notap[M]; // 给的序列中没有出现的元素 bool firstout; voi…
D. Diverse Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('…
贪心的选取最优解 然后相减好 记得要开long long #include <cstdio> #include <algorithm> #include <cstring> #include <set> #include <queue> #define int long long using namespace std; ,ansb=,posa=,posb=,n,a[],b[]; bool cmp(int a,int b){ if(a>b)…
A. Snacktower time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. S…
There are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior. There was a request to each of the workers to tell how how many…
E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个二进制不断地往右边移一位,每次答案加上这两个的交集,求最后的答案. 题解: 考虑第二个二进制每一位对答案的贡献就行了,然后对第一个二进制算前缀和就ok了. 代码如下: #include <bits/stdc++.h> using namespace std; typedef long long l…
http://codeforces.com/contest/1066/problem/D Maksim has nn objects and mm boxes, each box has size exactly kk. Objects are numbered from 11 to nn in order from left to right, the size of the ii-th object is aiai. Maksim wants to pack his objects into…
http://codeforces.com/contest/1066/problem/C You have got a shelf and want to put some books on it. You are given qq queries of three types: L idid — put a book having index idid on the shelf to the left from the leftmost existing book; R idid — put…
http://codeforces.com/contest/1066/problem/A Vova plans to go to the conference by train. Initially, the train is at the point 11 and the destination point of the path is the point LL. The speed of the train is 11 length unit per minute (i.e. at the…
orz 最近被水题卡+FST,各种掉rating 题目大意 一个数s它是n进制的,但是每一位不是用'A','B'....表示的,而是用10,11等等表示的,将它还原成十进制 这种表示方法显然会产生多解,然后求所有的解中最小的那个 这题一想就是贪心,但是一开始算法写渣了,改变思路以后才A的 简单来说就是从右边开始,把尽量多的数压到一位里面,这样会使数更小 压的思路可以这么考虑 每次新加进来一个数,如果加进来以后,已经大于原来的那个数,那么就找截取一段可行的最大数 这样考虑的目的是处理前导0带来的影…
#include<bits/stdc++.h>using namespace std;int mi[100007];int main(){ int cnt=0; int flag=0; int ans=1; int n,k=0; scanf("%d",&n); for(int i=2;i*i<=n;i++){ if(n%i==0){ flag=1; break; } } if(flag==0)//如果不用操作直接输出即可 printf("%d %d&…
http://codeforces.com/contest/1066/problem/F Maksim walks on a Cartesian plane. Initially, he stands at the point (0,0)(0,0) and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the…
题目链接:http://codeforces.com/problemset/problem/545/D 题解: 问经过调整,最多能使多少个人满意. 首先是排序,然后策略是:如果这个人对等待时间满意,则将其加入队伍中,更新当前的等候时间:如果不满意,既然等待时间最小了都不满意,那把他扔到最后,即跳过他,接着考虑下一个. 代码如下: #include<cstdio>//F - F CodeForces - 545D #include<cstring> #include<cstdl…