Codeforces Beta Round #2
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的更多相关文章
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- 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]中有多少个数 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
随机推荐
- C# 读取CSV文件
CSV文件是用逗号作为分隔符的,所以如果是简单的CSV文件,用split(',')就可以了. 但是Excel 编辑CSV文件,且内容中有逗号,得到的csv文件如下:"aaa,aaa" ...
- Delphi中线程类TThread实现多线程编程2---事件、临界区、Synchronize、WaitFor……
接着上文介绍TThread. 现在开始说明 Synchronize和WaitFor 但是在介绍这两个函数之前,需要先介绍另外两个线程同步技术:事件和临界区 事件(Event) 事件(Event)与De ...
- OCJP(1Z0-851) 模拟题分析(一)11
Exam : 1Z0-851 Java Standard Edition 6 Programmer Certified Professional Exam 以下分析全都是我自己分析或者参考网上的,定有 ...
- POJ1351 Number of Locks(数学)
截至写博客为止,貌似这是网上第一个采用数学公式来处理的. 网上的题解都是DFS或是动态规划,但感觉可以推公式直接用数学的方法处理,想了好久,终于推出公式. 题意:一个长度为n的由数字1,2,3,4 组 ...
- 攻城狮在路上(叁)Linux(十七)--- linux磁盘与文件管理概述
一.复习知识点: 1.扇区是最小的物理存储单位,大小为512bytes. 2.扇区组成一个圆,成为柱面,柱面是分区的最小单位. 3.第一个扇区很重要,因为包含了MBR(446字节)和分区表(64字节) ...
- vim配置方法
/etc/vimrc (公共的) ~/.vimrc (私人的) rpm -qa|grep vim 这个命令,如何vim已经正确安装,则会显示上面三个包的名称 全部安装 yum -y install v ...
- PHP+MYSQL+AJAX实现每日签到功能
一.web前端及ajax部分 文件index.html <html> <head> <meta http-equiv=Content-Type content=" ...
- Effective C++ 之 Item 2:尽量以 const, enum, inline 替换 #define
Effective C++ Chapter 1. 让自己习惯C++(Accustoming Yourself to C++) Item 2. 尽量以 const, enum, inline 替换 #d ...
- hdu 4114(状压dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4114 思路:首先是floyd预处理出任意两点之间的最短距离.dp[state1][state2][u] ...
- LoadRunner 场景运行error的几种情况
一. Error -27727: Step download timeout (120 seconds)has expired when downloading resource(s). Set th ...