首页 > TAG信息列表 > Saruman

POJ - 3069 Saruman‘s Army

Saruman’s Army POJ - 3069 AYIT-2021 609暑假集训第一周上 搜索和贪心 Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs,

Saruman's Army

  #include<cstdio> #include<iostream> #include<set> #include<algorithm> using namespace std; set<int> s; int main(void) { int R, n; while (cin >> R >> n && R != -1 && n != -1) {

POJ 3069 Saruman's Army

题目如下: 一个游戏:在一条直线上有N个糖果。第i个糖果的位置是X[i]。从这N个糖果中选择若干个,把他们标记起来。对于每一个糖果,在和它本身相距为R的区域内必须要有标记的糖果(本身带有标记的糖果,就可以认为和它相距为0的地方有一个糖果被标记)。在满足这个条件的情况,最后如果有a个糖果

POJ3069 -- Saruman's Army

题意: 直线上有N个点。 点i的位置是Xi。从这N个点中选择若干个,给它们加上标记。 对每一个点,其距离为R以内的区域里必须有带有标记的点(自己本身带有标记的点, 可以认为与其距离为 0 的地方有一个带有标记的点)。 在满足这个条件的情况下, 希望能为尽可能少的点添加标记。 请问至少要有

贪心法-------Saruman's army

此题的策略是选取可用范围最右边的点,一般来说该点辐射两边,左侧辐射,右侧辐射,所以用两个循环,第一个循环找出该点,第二个循环求出最右边的点 源代码: #include<iostream>#include<algorithm>using namespace std;#define maxn 1100int main(){    int r,n,k=0,num=0,x,a[maxn];  

POJ 3069 Saruman's Army

1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<queue> 5 #include<map> 6 #include<vector> 7 #include<set> 8 #include<string> 9 #include<cmath> 10 #include<cstring&g

Saruman‘s Army (POJ 3069)

直线上有N个点,点i的位置是Xi,从这N个点中选择若干个,给它们加上标记,对每一个点,其距离为R以内的区域里必须有带有标记的点(自己本身带有标记的点可以认为与其距离为0的地方有一个带有标记的点)。在满足这个条件的情况下,希望能为尽可能少的点添加标记,请问至少需要多少个点被加上标

题解:Saruman's Army(贪心)

Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective range of R units, and

poj 3069 Saruman's Army 贪心模拟

Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18794   Accepted: 9222 Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman di