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. Java Hour 64 JVM 最大内存设置

    从这篇博文起,不再是流水式的学习记录了,稍微改进下风格. 运行时获得当前JVM 设置大小 首先,-Xmx100000000指定最大的内存分配. public static void main(Stri ...

  2. Java 对象序列化(Serialization Object)

    官网文档:https://docs.oracle.com/javase/tutorial/jndi/objects/serial.html 优秀博客: http://www.cnblogs.com/g ...

  3. Centos7-mqtt消息中间件mosquitto的安装和配置

    在以前发布的博客"菜鸟是如何打造智能家居系统的"文章最后我提到了使用MQTT协议作为云平台和设备之间的通信协议以达到消息传递的实时性,手机的消息推送也大多基于这种平台,首先搬来一段 ...

  4. 智能车学习(十八)——电机学习

    一.C车电机选择 1.摘要:      因为C车模在四轮车的优势是有两个电机,可以进行主动差速,劣势是电机太弱了....所以如何选择电机,就是个钱的问题了,电机多一点,就比较好选,但是C车电机跑多了就 ...

  5. 【MyEcplise hibernate tools】hibernate tools的使用以及错误

    1.点击Myecplise右上角 2.点击进入后,在这个区域右键 New 一个新的connection 3.以mySql连接为例子,在这里展示一下,下面这几项必须都要按照要求完全一致,除了架包所在的本 ...

  6. XSS攻击&SQL注入攻击&CSRF攻击?

    - XSS(Cross Site Script,跨站脚本攻击)是向网页中注入恶意脚本在用户浏览网页时在用户浏览器中执行恶意脚本的攻击方式.跨站脚本攻击分有两种形式:反射型攻击(诱使用户点击一个嵌入恶意 ...

  7. a标签 打电话 发邮件

    打电话<a href=”tel:010-13220163333″>13220163333</a> 发邮件<a href=”mailto:sb@you.com”>发送 ...

  8. DSP using Matlab 书内练习Example 2.1

    先上代码,后出结果图. a. n = [-5:5]; x=2*impseq(-2,-5,5) - impseq(4,-5,5); set(gcf,'Color',[1,1,1]) % 改变坐标外围背景 ...

  9. css整理-03 文本

    缩进和水平对齐 缩进文本:text-indent 可以设置为负值 可以为所有块级元素应用,但无法应用到行内元素,图像之类的替换元素: 水平对齐: text-align left,center,righ ...

  10. 车销 商场 批发零售无线POS开单 智能POS开单打印 开单APP应用-云POS扫描打印一体方案

    PDA数据采集器,是一款移动手持开单设备,它通过WIFI和GPRS连接并访问电脑,从进销存软件中读取数据,实现移动开单,打破电脑开单模式. 它自带扫描器,可直接扫描条码来查找产品,且功能强大.操作简单 ...