codeforces #120 div 2 (Virtual Participation)

比赛链接

选区_033

选区_034

两题QAQ

A:7分钟1A 有n个大人m个小孩乘公交车,票价每人一元,一个大人最多免费带一个小孩,没有大人陪同的小孩不能乘车。 问是否有解,如果有解输出所有乘客付的钱的可能的最小值和可能的最大值。

思路:最小值就是先尽量利用每个大人带一个孩子。最大值就是把所有孩子都给一个大人。

特殊情况是:没有大人的时候,孩子不能乘车,无解。没有小孩的时候,大人没办法免费带孩子,也要特殊考虑。

/* ***********************************************
Author :111qqz
Created Time :2016年03月24日 星期四 12时24分27秒
File Name :code/cf/#120/A.cpp
************************************************ */
 1#include <cstdio>
 2#include <cstring>
 3#include <iostream>
 4#include <algorithm>
 5#include <vector>
 6#include <queue>
 7#include <set>
 8#include <map>
 9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#define fst first
14#define sec second
15#define lson l,m,rt<<1
16#define rson m+1,r,rt<<1|1
17#define ms(a,x) memset(a,x,sizeof(a))
18typedef long long LL;
19#define pi pair < int ,int >
20#define MP make_pair
 1using namespace std;
 2const double eps = 1E-8;
 3const int dx4[4]={1,0,0,-1};
 4const int dy4[4]={0,-1,1,0};
 5const int inf = 0x3f3f3f3f;
 6int n,m;
 7int mx,mi;
 8int main()
 9{
10	#ifndef  ONLINE_JUDGE 
11	freopen("code/in.txt","r",stdin);
12  #endif
 1	cin>>n>>m;
 2	if (n==0&&m>0)
 3	{
 4	    puts("Impossible");
 5	    return 0;
 6	}
 7	if (n==0&&m==0)
 8	{
 9	    cout<<0<<" "<<0<<endl;
10	    return 0;
11	}
12	if (m==0&&n>0)
13	{
14	    cout<<n<<" "<<n<<endl;
15	    return 0 ;
16	}
17	if (n>=m)
18	{
19	    mi = n ;
20	    mx = n-1+m;
21	}
22	else
23	{
24	    mi = n + m-n;
25	    mx = n-1+m;
26	}
27	cout<<mi<<" "<<mx<<endl;
1  #ifndef ONLINE_JUDGE  
2  fclose(stdin);
3  #endif
4    return 0;
5}

B:有两个被包围的城市,给出城市的坐标以及敌人距离城市的距离。敌人向着城市移动。要求建一个雷达,使得雷达能够感应到两伙敌人(分别朝着两个方向移动)的“the start of the movements”。问雷达的最小半径是多少。

反思:思维不够清楚,太呆

思路:两个圆有**五种(一开始想成了三种,所以wa7)**位置关系,分别考虑。

相离时,答案为(圆心距-半径之和)/2

外切时:把雷达建在切点,答案为0.

相交时:把雷达建在交点,答案为0

内切时:把雷达建在交点,答案为0.

内含时:答案为(abs(半径之差)-圆心距离)/2.

/* ***********************************************
Author :111qqz
Created Time :2016年03月24日 星期四 12时53分05秒
File Name :code/cf/#120/BB.cpp
************************************************ */
 1#include <cstdio>
 2#include <cstring>
 3#include <iostream>
 4#include <algorithm>
 5#include <vector>
 6#include <queue>
 7#include <set>
 8#include <map>
 9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#define fst first
14#define sec second
15#define lson l,m,rt<<1
16#define rson m+1,r,rt<<1|1
17#define ms(a,x) memset(a,x,sizeof(a))
18typedef long long LL;
19#define pi pair < int ,int >
20#define MP make_pair
 1using namespace std;
 2const double eps = 1E-8;
 3const int dx4[4]={1,0,0,-1};
 4const int dy4[4]={0,-1,1,0};
 5const int inf = 0x3f3f3f3f;
 6int a,b,r1;
 7int c,d,r2;
 8int dblcmp(double d)
 9{
10    return d<-eps?-1:d>eps;
11}
12int main()
13{
14	#ifndef  ONLINE_JUDGE 
15	freopen("code/in.txt","r",stdin);
16  #endif
17	cin>>a>>b>>r1;
18	cin>>c>>d>>r2;
19	double dis = sqrt((a-c)*(a-c)+(b-d)*(b-d));
20	double r = r1+r2;
21	if (dblcmp(r-dis)==0)
22	{
23	    puts("0.0000000000000000");
24	    return 0;
25	}
 1	if (dblcmp(r-dis)<0)
 2	{
 3	    double ans = (dis-r)*0.5;
 4	    printf("%.16f\n",ans);
 5	}
 6	if (dblcmp(r-dis)>0)
 7	{
 8	    if (dblcmp(dis-abs(r1-r2))>=0)
 9	    {
10		puts("0.00000000000000");
11	    }
12	    if (dblcmp(dis-abs(r1-r2))<0)
13	    {
14		double ans = (abs(r1-r2)-dis)*0.5;
15		printf("%.15f\n",ans);
16	    }
1	}
2  #ifndef ONLINE_JUDGE  
3  fclose(stdin);
4  #endif
5    return 0;
6}

C:给出一个pair 和int 序列,问能否恢复成一个合法的类型表示。如果能,保证有唯一解,输出这个唯一解。

细节略多。

没搞出来QAQ