A题,神题意题。。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
vector<string> ve;
map<string,int>mp;
map<string,int>mz;
int p[];
int main()
{
int n,maxz,i;
string str;
cin>>n;
for(i = ;i < n;i ++)
{
cin>>str>>p[i];
mp[str] = ;
mz[str] = ;
ve.push_back(str);
}
for(i = ;i < n;i ++)
{
mp[ve[i]] += p[i];
}
for(map<string,int>::iterator it = mp.begin();it != mp.end();it ++)
{
maxz = max(maxz,it->second);
}
for(i = ;i < n;i ++)
{
mz[ve[i]] += p[i];
if(mz[ve[i]] >= maxz&&mp[ve[i]] == maxz)
{
cout<<ve[i]<<endl;
break;
}
}
return ;
}

B题,以前做过,经典的DP。链接

C题,模拟退火,水过,改了很多几下参数...正解,是解方程 什么的。

#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
#define eps 1e-10
int a[] = {,,,-};
int b[] = {,-,,};
struct point
{
double x,y;
};
point p[];
double r[];
double dis(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
}
point Rotate(point p,double angle)
{
point res;
res.x = p.x*cos(angle) - p.y*sin(angle);
res.y = p.x*sin(angle) + p.y*cos(angle);
return res;
}
double CirPoint(point a,point b,double r)
{
double line = sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
return line/r;
}
int main()
{
double x,y;
int i,j;
srand(time(NULL));
x = y = ;
for(i = ;i < ;i ++)
{
scanf("%lf%lf%lf",&p[i].x,&p[i].y,&r[i]);
x += p[i].x;
y += p[i].y;
}
x = x/;
y = y/;
double temp[],avg,tsqs;
double sqs = ;
point ans,t;
ans.x = ;
ans.y = ;
int T = ,key,k,flag = ;
key = ;//key步长,T是温度
while(T --)
{
for(i = ;i < ;i ++)
{
k = rand()%key;
t.x = x + k*a[i]*T/100000.0;
t.y = y + k*b[i]*T/100000.0;
avg = ;
//利用 点到圆心距离 与 半径之比 表示这个角度
for(j = ;j < ;j ++)
{
temp[j] = CirPoint(t,p[j],r[j]);
avg += temp[j];
}
avg = avg/;
tsqs = ;
for(j = ;j < ;j ++)//方差
{
tsqs += (temp[j]-avg)*(temp[j]-avg);
}
if(sqs > tsqs)
{
sqs = tsqs;
x = t.x;
y = t.y;
}
if(tsqs < eps&&tsqs > -eps)
{
flag = ;
if(dis(p[],t) < dis(p[],ans))
ans = t;
}
}
}
if(flag)
printf("%lf %lf\n",ans.x+eps,ans.y+eps);
return ;
}

Codeforces Beta Round #2的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  3. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  4. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  5. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  6. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  7. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  9. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  10. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

随机推荐

  1. ***电商数据库设计参考:ecshop数据库+订单表结构等

    ecshop订单表结构ecs_order_info说明 -- 表的结构 `ecs_order_info`    CREATE TABLE IF NOT EXISTS `ecs_order_info` ...

  2. 【JAVA正则表达式】

    一.String类. java.lang.Object |--java.lang.String 常用方法:  String replaceAll(String regex, String replac ...

  3. 【PHP用户的错误日志】

    将产生的错误保存在日志中的方法:使用error_log方法,其中,当日志类型是3的时候,下一个参数将会是日志文件的保存路径 使用示例: <?php function myerror($level ...

  4. sdut1598 周游列国【简单模拟题】

    周游列国 Time Limit: 1000ms   Memory limit: 32768K  有疑问?点这里^_^ 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/p ...

  5. dbca:Exception in thread "main" java.lang.UnsatisfiedLinkError: get

    在64位的操作系统安装oracle10g 软件安装完成后,使用dbca建库的时候报下面的错: $ dbcaUnsatisfiedLinkError exception loading native l ...

  6. W:Failed to fetch http://archive.ubuntukylin.com:10006/ubuntukylin/dists/pre

    由于用ubuntu的时候装了几个ubuntukylin的软件(像搜狗拼音for linux),于是最近总是蹦出一个红色的三角提示,说无法更新,虽说不影响使用但是还是很不爽.解决方法记录如下: 进入系统 ...

  7. IM服务器的架构

    一. 总的构架结构示意图: 如上图所示,目前系统总的分成六个模块, 分别为网络/协议解析模块,用户帐号管理模块,消息处理模块,动作处理模块,数据均衡处理模块,客户状态处理模块 . 正常流程应该这么实现 ...

  8. Jquery禁止/恢复按钮与文本框代码

    最近,加入了一个小项目,由浩哥带领我们几个人一起开发一个东西.幸运的是,我和胡志婷分到了一组,她可是一个具有丰富经验的牛人,对我也很好,哈哈. --背景 说点正事,最近,我们在进行项目的时候,提到了一 ...

  9. MFC中afx_msg是什么,afx_msg void function()是什么意思

    应用程序框架产生的消息映射函数例如:afx_msg void OnBnClickedButton1(); 其中 afx_msg为消息标志,它向系统声明:有消息映射到函数实现体:而在map宏定义中,就有 ...

  10. 多态、类库、委托、is和as运算符、泛型集合

    多态:简而言之就是龙生九子,各有不同 有了继承,才有了多态 1.虚方法 virtual 重写 override 父类中的方法,在子类中并不适用,那么子类需要自主更改继承的方法或者是属性,那父类中加了v ...