A. Winner

  题目大意:一些人在玩游戏,给出n次某人获得的分数,现在请计算出胜者,如果不止一个最高分,则取最先达到该分数的人。

  题解:模拟得分过程,首先计算出最高分,然后获取先到达或超过最高分的人。

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;
vector<string> name;
vector<int> score;
map<string,int> sum,sum1;
int Max=0,x;
string s;
int main(int n){
scanf("%d",&n);
for(int i=0;i<n;i++){
cin>>s>>x;
name.push_back(s);
score.push_back(x);
sum[name[i]]+=score[i];
}for(int i=0;i<n;i++){if(sum[name[i]]>Max)Max=sum[name[i]];}
for(int i=0;i<n;i++){
if(sum[name[i]]<Max||(sum1[name[i]]+=score[i])<Max)continue;
cout<<name[i]<<endl; break;
}
}

B. The least round way 

  题目大意:找一条从给出的数字矩阵左上角到右下角的道路,使得该路上所有数字的乘积后面的0最少。求出路径和最小的0数目。

  题解:首先如果路径中有0,那么答案就是1,否则就是道路中数字中因子2和因子5的最小值(因为2和5配对才可以产生0),计算2和5的个数的过程用记忆化搜索,路径记录则由已知的DP值倒推获得。

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int N=1005;
const int inf=~0U>>2;
int dp[N][N],M[N][N],b[N][N],ans=inf,n;
string road;
void dfs(int x,int y){
if(x&&dp[x][y]==b[x][y]+dp[x-1][y]){dfs(x-1,y);road.push_back('D');}
else if(y){dfs(x,y-1);road.push_back('R');}
}
void solve(int c){
rep(i,n)rep(j,n){int x=0;while(M[i][j]&&M[i][j]%c==0)M[i][j]/=c,x++;b[i][j]=x;}
rep(i,n)rep(j,n){
if(i)dp[i][j]=b[i][j]+dp[i-1][j];
else if(j)dp[i][j]=b[i][j]+dp[i][j-1];
else dp[i][j]=b[i][j];
if(i)dp[i][j]=min(dp[i][j],b[i][j]+dp[i-1][j]);
if(j)dp[i][j]=min(dp[i][j],b[i][j]+dp[i][j-1]);
}
if(ans>dp[n-1][n-1]){
ans=dp[n-1][n-1];
road=""; dfs(n-1,n-1);
}
}
int main(){
scanf("%d",&n);
rep(i,n)rep(j,n)scanf("%d",&M[i][j]);
solve(2);solve(5);
rep(i,n)rep(j,n)if(M[i][j]==0&&ans>1){
ans=1;road="";
rep(k,i)road.push_back('D');
rep(k,j)road.push_back('R');
rep(k,n-i-1)road.push_back('D');
rep(k,n-j-1)road.push_back('R');
}cout<<ans<<endl<<road<<endl;
return 0;
}

C. Commentator problem

  题目大意:给出三个圆(坐标,半径),求一个点,使得它与三个圆切线所形成的角相等,如果无法找到,则不输出

  题解:首先将起点定位在三个点形成的三角形的重心,然后模拟退火,以1为起步长,不断重新调整选取点的位置,使得其最终符合要求。如果达到精度后无法满足,则不输出。

#include <cstdio>
#include <cmath>
using namespace std;
const double EPS=1e-6;
int d[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
struct C{double x,y,r;}c[3];
double dist(double x1,double y1,double x2,double y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
double f(double x,double y){
double u[3],ans=0;
for(int i=0;i<3;i++)u[i]=dist(x,y,c[i].x,c[i].y)/c[i].r;
for(int i=0;i<3;i++)ans+=(u[i]-u[(i+1)%3])*(u[i]-u[(i+1)%3]);
return ans;
}
int main(){
double x=0,y=0,step=2;
for(int i=0;i<3;i++){scanf("%lf%lf%lf",&c[i].x,&c[i].y,&c[i].r);x+=c[i].x/3;y+=c[i].y/3;}
while(step>EPS){
double tmp=f(x,y);
int flag=-1;
for(int i=0;i<4;i++){
double tmp1=f(x+d[i][0]*step,y+d[i][1]*step);
if(tmp1<tmp){tmp=tmp1;flag=i;}
}if(flag==-1)step/=2;
else{x=x+d[flag][0]*step;y=y+d[flag][1]*step;}
}if(f(x,y)<EPS)printf("%.5lf %.5lf\n",x,y);
return 0;
}

  

Codeforces Round#2的更多相关文章

  1. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  7. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  8. Codeforces Round #370 - #379 (Div. 2)

    题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi  ...

  9. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

  10. Codeforces Round #284 (Div. 2)A B C 模拟 数学

    A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...

随机推荐

  1. OC语法7——内存管理之@property参数

    @property的参数: 我们已经知道为了给开发者提供便捷,OC提供了@porperty关键字,它可以自动生成属性的set和get方法. 但是我们又知道,在OC中还面临者对象内存管理的问题,而且我们 ...

  2. ubuntu中Mysql常用命令整理

    启动mysql服务sudo /etc/init.d/mysql start 关闭mysql服务sudo /etc/init.d/mysql stop

  3. sersync+inotify实时备份数据

    Sersync项目简介与框架 简介 Sersync项目利用inotify与rsync技术实现对服务器数据实时同步的解决方案,其中inotify用于监控sersync所在服务器上文件系统的事件变化,rs ...

  4. $.browser.msie jq解析不出来的原因及解决方法

    检查是否为 IE6:// Oldif ($.browser.msie && 7 > $.browser.version) {}// Newif ('undefined' == t ...

  5. Flink资料(7) -- 背压监控

    背压(backpressure)监控 本文翻译自Back Pressure Monitoring --------------------------------------------------- ...

  6. hdu 5649 DZY Loves Sorting 二分+线段树

    题目链接 给一个序列, 两种操作, 一种是将[l, r]里所有数升序排列, 一种是降序排列. 所有操作完了之后, 问你a[k]等于多少. 真心是涨见识了这题..好厉害. 因为最后只询问一个位置, 所以 ...

  7. python filter内建函数

    以下是filter函数的官方文档,注意最后一段,当function不为None时,函数相似于[item for item in iterable if function(item)],function ...

  8. [原创]obj-c编程15[Cocoa实例02]:KVC和KVO的实际运用

    原文链接:obj-c编程15[Cocoa实例02]:KVC和KVO的实际运用 我们在第16和第17篇中分别介绍了obj-c的KVC与KVO特性,当时举的例子比较fun,太抽象,貌似和实际不沾边哦.那么 ...

  9. getchar()与EOF

    大师级经典的著作,要字斟句酌的去读,去理解.以前在看K&R的The C Programming Language(Second Edition)中第1.5节的字符输入/输出,很迷惑getcha ...

  10. 嵌入式davinci电路元素基础和PWM模块

    1,DAC_OUT和DAC_OUTB是AD9912输出的差分信号. 2,电容器储存电荷的能力,常用的单位是F.uF.nF.pFUF大了好还是UF小了好,要根据电路自身需要而设计, 要看电路滤波是在高频 ...