题意:

  给出n(<=1000)条线段的长度ai(<=10^500),输出任意三条能组成三角形的边.没有输出3个0.

Solution:

  简单题.只是要处理高精度.

java大法好.

import java.util.*;
import java.math.*;
public class Solution {
public static void main(String[] args){
Scanner cin=new Scanner(System.in);
int n=cin.nextInt();
BigInteger[] a=new BigInteger[1009];
for(int i=1;i<=n;++i){
a[i]=cin.nextBigInteger();
}
Arrays.sort(a,1,n+1);
for(int i=1;i<=n;++i){
for(int j=i+1;j<n;++j){
if(a[i].add(a[j]).compareTo(a[j+1])==1){
System.out.println(a[i]+" " + a[j]+ " "+ a[j+1]);
System.exit(0);
}
}
}
System.out.println("0 0 0");
}
}

SGU 299.Triangle的更多相关文章

  1. 今日SGU 5.29

    sgu 299 题意:给你n个线段,然后问你能不能选出其中三个组成一个三角形,数字很大 收获:另一个大整数模板 那么考虑下为什么如果连续三个不可以的话,一定是不存在呢? 连续上个不合法的话,一定是 a ...

  2. SGU 分类

    http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...

  3. [LeetCode] Triangle 三角形

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...

  4. [LeetCode] Pascal's Triangle II 杨辉三角之二

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...

  5. [LeetCode] Pascal's Triangle 杨辉三角

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  6. 【leetcode】Pascal's Triangle II

    题目简述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Retur ...

  7. 【leetcode】Pascal's Triangle

    题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...

  8. POJ 1163 The Triangle(简单动态规划)

    http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissi ...

  9. Triangle - Delaunay Triangulator

    Triangle - Delaunay Triangulator  eryar@163.com Abstract. Triangle is a 2D quality mesh generator an ...

随机推荐

  1. JavaScript高级程序设计45.pdf

    客户区坐标位置 clientX和clientY保存着鼠标指针在视口中的水平位置坐标和垂直位置坐标(显示出页面的部分叫做客户区,坐标信息不包括页面的滚动距离) var div=document.getE ...

  2. [ZETCODE]wxWidgets教程三:第一个窗体程序

    本教程原文链接:http://zetcode.com/gui/wxwidgets/firstprograms/ 翻译:瓶哥 日期:2013年11月27日星期三 邮箱:414236069@qq.com ...

  3. 最短路SPFA

    用邻接矩阵a表示一幅图,a[i][j]表示从点i到点j的边长,如果为0则无边.(这是无负边,0边的情况) 这张图有T个点,C条边,要求求出从Ts走到Te的最短路. 用f[i]表示从Ts走到i点的最短路 ...

  4. 浙大PTA - - File Transfer

    题目链接:https://pta.patest.cn/pta/test/1342/exam/4/question/21732 #include "iostream" #includ ...

  5. Java分布式优秀资源集合

    这里充分尊重原作者的版本,学习了知识要感激原博主 Runnable.Callable.Executor.Future.FutureTask关系解读 http://blog.csdn.net/zhang ...

  6. jOOQ

    jOOQ http://www.jooq.org/ jOOQ是个更不错的SQL解决方案. 你可以在Java中以一种类型安全的方式来书写SQL语句: // Typesafely execute the ...

  7. [C#] 常用工具类——系统日志类

    using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespa ...

  8. 自定义String类,并且实现在STL容器中添加自定义的类型

    13.44 编写标准库string类的简化版本,命名String.你的类应该至少有一个默认构造函数和一个接受C风格字符串指针参数的构造函数.使用allocator为你的String类分配所需内存. 1 ...

  9. iOS 关于开发者证书:此证书的签发者无效的解决方案

    备注:第二个步骤一定要进行,否则弄到吐血,还是现实签发者无效 ---------------------- 1,按照你那个链接下载,https://developer.apple.com/certif ...

  10. kvm安装及配置

     yum install kvm libvirt python-virtinst qemu-kvm virt-viewer bridge-utils virt-install 修改网卡信息 /etc/ ...