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. 解决Pyqt打包后运行报错:应用程序无法启动 因为程序的并行配置不正确

    做了一个生成二维码的小程序:http://www.cnblogs.com/dcb3688/p/4241048.html 直接运行脚本没问题,用pyinstaller打包后再运行就直接报错了: 应用程序 ...

  2. Snowflake Snow Snowflakes(哈希表的应用)

    Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 27312   Accep ...

  3. SQLAlchemy Core中的异常及事务处理样码

    这部门内容比较简单,立存. #coding=utf-8 from datetime import datetime from sqlalchemy import (MetaData, Table, C ...

  4. [LeetCode] Ugly Number

    Ugly Number Total Accepted: 20760 Total Submissions: 63208 Difficulty: Easy Write a program to check ...

  5. log4j设置日志格式为UTF-8

    想要log4j输出的日志文件的编码格式为UTF-8.正常情况下只需要添加下述的代码即可: log4j.appender.appender_name.Encoding=UTF-8 但是在spring与l ...

  6. markdown使用总结

    # markdown简介> Markdown 是一种轻量级标记语言,它允许人们使用易读易写的纯文本格式编写文档,然后转换成格式丰富的HTML页面. —— [维基百科]( https://zh.w ...

  7. Flash Media Server 4.0 破解 注册

    Adobe Flash Media Interactive Server 3.5s/n:1373-5047-2985-0514-5175-0098 s/n: 1373-5632-4666-9521-8 ...

  8. codeforce ABBYY Cup 3.0 - Finals (online version) B2. Shave Beaver! 线段树

    B2. Shave Beaver!   The Smart Beaver has recently designed and built an innovative nanotechnologic a ...

  9. NSDate用法整理总结

    int main(int argc, const char * argv[]) { @autoreleasepool { NSDate *date=[NSDate date]; NSLog(@&quo ...

  10. CmRegisterCallback使用方法

    部分代码 #include "my_sys_fun.h"#ifdef __cplusplusextern "C"{#endif //驱动加载函数 NTSTATU ...