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 ;
}

最新文章

  1. OBS-Studio二次开发记录
  2. TypeScript 中的 &quot;=&gt;&quot; 真的很好用!!!
  3. matlab clear
  4. 500-internal server error 错误提示到配置文件的某行,并显示乱码
  5. spring security方法一 自定义数据库表结构
  6. 复旦大学2014--2015学年第二学期高等代数II期末考试情况分析
  7. JavaScript,一个超级简单的方法判断浏览器的内核前缀
  8. AIR 3.0针对移动设备的高性能渲染方案
  9. JavaScript--模块化编程(笔记)
  10. HTML5之图形变换
  11. 深入理解object C中复制对象的用法(一)
  12. xlsx导入成--json
  13. xlwt以格式生成xls文件
  14. Task 的用法
  15. python04 列表 元祖 字典
  16. luogu-1563玩具谜题
  17. Centos 7 KVM安装win10
  18. Java WEB 笔记
  19. 51nod1042
  20. [UE4]Slot

热门文章

  1. PHP面向对象编程之深入理解方法重载与方法覆盖(多态)
  2. .NET Nancy 详解(二) 简易路由实现
  3. 手机WebAPP设计注意事项和解决方法
  4. PHP json数据格式化方法
  5. 卸载已经安装的rpm包
  6. 禁用编译器自动生成的函数(Effective C++之06)
  7. Asp.Net MVC中DropDownListFor的用法
  8. HDU 3586 Information Disturbing 树形DP+二分
  9. Build better apps: Windows 10 by 10 development series
  10. java中static作用详解