时间限制:5000ms
单点时限:1000ms
内存限制:256MB

描述

Given a circle on a two-dimentional plane.

Output the integral point in or on the boundary of the circle which has the largest distance from the center.

输入

One line with three floats which are all accurate to three decimal places, indicating the coordinates of the center x, y and the radius r.

For 80% of the data: |x|,|y|<=1000, 1<=r<=1000

For 100% of the data: |x|,|y|<=100000, 1<=r<=100000

输出

One line with two integers separated by one space, indicating the answer.

If there are multiple answers, print the one with the largest x-coordinate.

If there are still multiple answers, print the one with the largest y-coordinate.

样例输入
1.000 1.000 5.000
样例输出
6 1
// Java版本
import java.util.Scanner; public class Main {
/* 2
0 0
0 3 1.000 1.000 5.000 */ public static void main(String[] args) { Scanner scanner = new Scanner(System.in);
double x,y,r;
x=scanner.nextDouble();
y=scanner.nextDouble();
r=scanner.nextDouble(); int ll=(int) (x-r);
int lr=(int)(x+r);
int iya,iyb;
double max=-1;
double tmp;
double r2=r*r;
double result;
int maxx=(int) x,maxy=(int) y;
for(int ix=ll; ix<=lr; ++ix){
//计算对应的iy
tmp=Math.sqrt(r2-(ix-x)*(ix-x));
iya=(int) (tmp+y)-1;
iyb=(int) (y-tmp)-1;
//System.out.println(iya+" "+ iyb);
result =( iyb-y)*( iyb-y)+(ix-x)*(ix-x);
if(Double.compare(Math.sqrt(result), r)<=0&&Double.compare(result, max)>=0){ //大于等于
max=result;
maxx=ix;
maxy=iyb;
} iyb++;
result =( iyb-y)*( iyb-y)+(ix-x)*(ix-x);
if(Double.compare(Math.sqrt(result), r)<=0&&Double.compare(result, max)>=0){ //大于等于
max=result;
maxx=ix;
maxy=iyb;
} iyb++;
result =( iyb-y)*( iyb-y)+(ix-x)*(ix-x);
if(Double.compare(Math.sqrt(result), r)<=0&&Double.compare(result, max)>=0){ //大于等于
max=result;
maxx=ix;
maxy=iyb;
} result =( iya-y)*( iya-y)+(ix-x)*(ix-x);
if(Double.compare(Math.sqrt(result), r)<=0&&Double.compare(result, max)>=0){ //大于等于
max=result;
maxx=ix;
maxy=iya;
}
iya++;
result =( iya-y)*( iya-y)+(ix-x)*(ix-x); if(Double.compare(Math.sqrt(result), r)<=0&&Double.compare(result, max)>=0){ //大于等于
max=result;
maxx=ix;
maxy=iya;
} iya++;
result =( iya-y)*( iya-y)+(ix-x)*(ix-x);
if(Double.compare(Math.sqrt(result), r)<=0&& Double.compare(result, max)>=0){ //大于等于
max=result;
maxx=ix;
maxy=iya;
}
} System.out.println(maxx+" "+maxy);
scanner.close();
} public static void main2(String[] args) { Scanner scanner = new Scanner(System.in);
double x,y,r;
x=scanner.nextDouble();
y=scanner.nextDouble();
r=scanner.nextDouble(); int ll=(int) (x-r);
int lr=(int)(x+r);
int ya=(int) (y+r);
int yb=(int) (y-r);
double max=-1;
double tmp;
double result;
double r2=r*r;
int maxx=(int) x,maxy=(int) y;
for(int ix=ll; ix<=lr; ++ix){
//计算对应的iy for( int iy=yb; iy<=ya; ++iy){
result =( iy-y)*( iy-y)+(ix-x)*(ix-x);
if(Double.compare(result, r2)<=0){ //如果在里面
if(Double.compare(result, max)>=0){
max=result;
maxx=ix;
maxy=iy;
}
}
}
} System.out.println(maxx+" "+maxy);
scanner.close();
}
}
 

最新文章

  1. tornado学习笔记19 Tornado框架分析
  2. shell脚本删除指定mobileprovision
  3. 由一段JS代码引发的思考
  4. html5的spellcheck属性(拼写、文法检查)
  5. 微软BI 之SSIS 系列 - 再谈Lookup 缓存
  6. 远程办公《Remote》读书笔记:中国程序员在家上班月入过六万不是梦
  7. Mysql存储引擎
  8. 跳出frameset框架
  9. 字典树trie的学习与练习题
  10. Oracle数据库“Specified cast is农田valid”
  11. shell 流程控制
  12. android 中 ColorDrawable dw = new ColorDrawable(0x3ccccccc),关于颜色定义的总结
  13. java读取网页
  14. 建立一个ROS msg and srv
  15. H5_background-clip(css3——裁剪)
  16. 洛谷银牛派对SPFA
  17. leetcode刷题第二天&lt;两数相加&gt;
  18. CEF 右键添加开发者选项菜单项
  19. 【HTML入门基础知识】从零开始,我要加油!---致HTML
  20. Linux 各种软件的安装-Jenkins和svn结合

热门文章

  1. Best Time to Buy and Sell Stock with Cooldown -- LeetCode
  2. Struts2笔记--文件下载
  3. static静态变量-投票案例
  4. Netbeans 中部署运行Webservice出错
  5. Android Developer -- Bluetooth篇 概述
  6. SQL 序号列ROW_NUMBER,RANK,DENSE_RANK、NTILE
  7. Winform打砖块游戏制作step by step第6节---画墙(砖块集合)以及双缓冲实现
  8. Javascript中的原型链、prototype、__proto__的关系
  9. 远程访问CENTOS的MYSQL数据库设置
  10. OpenGL投影矩阵【转】