// 最短两边大于最长边即可。核心代码总量:7行 AC!importjava.math.BigInteger;importjava.util.Arrays;importjava.util.Scanner;publicclassMain {publicstaticvoidmain(String[] args) {Scanner in = newScanner(System.in);while(in.hasNext()){BigInteger[] arr=newBigInteger[3];for(inti = 0; i < 3; i++) {arr[i]=newBigInteger(in.next());}Arrays.sort(arr);if(arr[0].add(arr[1]).compareTo(arr[2])>0){System.out.println("Yes");}else{System.out.println("No");}}}}
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
public static void main(String args[]){
Scanner in=new Scanner(System.in);
boolean k;
BigInteger a,b,c;
while(in.hasNext()){
a=in.nextBigInteger();
b=in.nextBigInteger();
c=in.nextBigInteger();
k=true;
if((a.add(b)).compareTo(c)<=0) k=false;
if((b.add(c)).compareTo(a)<=0) k=false;
if((a.add(c)).compareTo(b)<=0) k=false;
if(k) System.out.println("Yes");
else System.out.println("No");
}
}
}
int main()
{
printf("请输入三条边,用空格隔开\n");
while (1)
{
int a[3] = {0};
scanf("%d %d %d",&a[0],&a[1],&a[2]);
for (int i = 0;i < 3; i++)
{
if ((a[i] < a[(i+1)%3] + a[(i+2)%3]) && (a[i] > a[(i+1)%3] - a[(i+2)%3]) && (a[i] > a[(i+2)%3] - a[(i+1)%3]))
{
}
else{
printf("NO\n");
break;
}
printf("YES\n");
break;
}
}
return 0;
}
用字符串表示整数,定义加法和比较大小的函数
#include <iostream>
#include <string>
using namespace std;
string add(string s1, string s2) {
int len1 = s1.size();
int len2 = s2.size();
string res = "";
int i, j, k , t = 0;
for (i=len1-1, j=len2-1; i>=0 && j>=0; i--, j--) {
k = (s1[i]-'0') + (s2[j] - '0') + t;
res = (char)(k % 10 + '0') + res;
t = k / 10;
}
while (i>=0) {
k = (s1[i]-'0') + t;
res = (char)(k % 10 + '0') + res;
t = k / 10;
i--;
}
while (j>=0) {
k = (s2[j]-'0') + t;
res = (char)(k % 10 + '0') + res;
t = k / 10;
j--;
}
if (t>0) {
res = (char) (t + '0') + res;
}
return res;
}
bool great(string s1, string s2) {
int len1 = s1.size();
int len2 = s2.size();
if (len1 > len2)
return true;
else if (len1 < len2)
return false;
else {
return s1 > s2;
}
}
int main() {
string a, b, c;
while (cin>>a>>b>>c) {
if (great(add(a,b), c) && great(add(a,c),b) && great(add(b,c),a))
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
}
import java.math.BigInteger;
import java.util.Scanner;
public class Demo64 {
public static void main(String[] args) {
try(Scanner input = new Scanner(System.in)){
BigInteger a = null;
BigInteger b = null;
BigInteger c = null;
while (input.hasNextBigInteger()){
a = input.nextBigInteger();
b = input.nextBigInteger();
c = input.nextBigInteger();
BigInteger max = a.max(b.max(c));
BigInteger min = a.min(b.min(c));
BigInteger mid = a.add(b.add(c)).subtract(max).subtract(min);
String result = (max.compareTo(min.add(mid)) < 0) ? "Yes" : "No";
System.out.println(result);
}
}
}
} #include <iostream>
#include <string>
using namespace std;
void sum(string& a, string& b, string& ab) {
int i = a.size() - 1, j = b.size() - 1, k = ab.size() - 1;
int carry = 0;
while (j >= 0 || carry) {
int n1 = i >= 0 ? a[i--] - '0' : 0;
int n2 = j >= 0 ? b[j--] - '0' : 0;
ab[k--] = (n1 + n2 + carry) % 10 + '0';
carry = (n1 + n2 + carry) / 10;
}
}
bool cmp(string& a, string& b, string& c) {
if (b.size() < c.size() - 1) return false; // 从数量级上先判断
string ab(b.size() + 1, 0); // a + b 后可能会进位,预留一位
sum(a, b, ab);
int i = 0, j = 0;
if (ab[0] == 0) i++; // 说明预留的一位没有用上
if (ab.size() - i < c.size() - j) return false;
else if (ab.size() - i > c.size() - j) return true;
while (i < ab.size()) {
if (ab[i] < c[j]) return false;
else if (ab[i] > c[j]) return true;
i++;
j++;
}
return false; // a + b = c
}
int main() {
string a, b, c;
while (cin >> a >> b >> c) {
if (a.size() > b.size() || (a.size() == b.size() && a > b)) a.swap(b); // 确保 a < b < c
if (a.size() > c.size() || (a.size() == c.size() && a > c)) a.swap(c);
if (b.size() > c.size() || (b.size() == c.size() && b > c)) c.swap(b);
if (cmp(a, b, c)) cout << "Yes" << endl;
else cout << "No" << endl;
}
} import java.math.BigInteger;
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
BigInteger a=sc.nextBigInteger();
BigInteger b=sc.nextBigInteger();
BigInteger c=sc.nextBigInteger();
if(a.add(b).compareTo(c)>0 && a.add(c).compareTo(b)>0 && b.add(c).compareTo(a)>0)
System.out.println("Yes");
else
System.out.println("No");
}
}
}
while (in.hasNext()){ String line = in.nextLine(); String[] part = line.split(" "); BigInteger a = new BigInteger(part[0]); BigInteger b = new BigInteger(part[1]); BigInteger c = new BigInteger(part[2]); // BigInteger max = a > b ?(a > c ? a : c) : (b > c ? b : c); //找最大数 BigInteger max = (a.compareTo(b) > 0) ? (a.compareTo(c) > 0 ? a : c) : (b.compareTo(c) > 0 ? b : c); //最小2边和 BigInteger sum = max.equals(a) ? b.add(c) : (max.equals(b) ? a.add(c) : a.add(b)); //判断:sum>max String result = (sum.compareTo(max)>0)? "Yes" : "No"; System.out.println(result); } } } }
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
// long a = sc.nextLong();
// long b = sc.nextLong();
// long c = sc.nextLong();
BigInteger a = new BigInteger(sc.next());
BigInteger b = new BigInteger(sc.next());
BigInteger c = new BigInteger(sc.next());
if (isTriangle(a, b, c)) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}
public static boolean isTriangle(BigInteger a, BigInteger b, BigInteger c) {
// return a + b > c && a + c > b && b + c > a;
return a.add(b).compareTo(c) > 0 && a.add(c).compareTo(b) > 0 && b.add(c).compareTo(a) > 0;
} 很暴力很弱智一看就懂的代码
#include <iostream>
#include<algorithm>
using namespace std;
bool getnum(string a, string b) {
if (a.length() > b.length())
return true;
else if (a.length() == b.length()) {
auto la = a.begin();
auto lb = b.begin();
while (la != a.end()) {
if (*la > *lb)
return true;
if (*la < *lb)
return false;
la++;
lb++;
}
if (la == a.end())
return false;
}
else
return false;
return false;
}
void getred(string a, string b, string c) {
string tmp;
reverse(b.begin(), b.end());
reverse(c.begin(), c.end());
auto lb = b.begin();
auto lc = c.begin();
int adv = 0;
while (lb != b.end() && lc != c.end()) {
int pos = (*lb - '0') + (*lc - '0') + adv;
tmp += (pos % 10 + '0');
adv = pos / 10;
++lb;
++lc;
}
while (lb != b.end()) {
int pos = (*lb - '0') + adv;
tmp += (pos % 10 + '0');
adv = pos / 10;
++lb;
}
while (lc != c.end()) {
int pos = (*lc - '0') + adv;
tmp += (pos % 10 + '0');
adv = pos / 10;
++lc;
}
if(adv!=0)
tmp+=(adv+'0');//这里万万不能漏掉
reverse(tmp.begin(), tmp.end());
getnum(tmp, a) == 1 ? cout << "Yes" << endl : cout << "No" << endl;
return;
}
void istria(string a, string b, string c) {
string sum, red, mid;
if (getnum(a, b) == 1) {
sum = b;
red = (getnum(a, c) == 1 ? a : c);
mid = (getnum(a, c) == 0 ? a : c);
}
else {
sum = a;
red = (getnum(b, c) == 1 ? b : c);
mid = (getnum(b, c) == 0 ? b : c);
}
getred(red, mid, sum);
}
int main() {
string a, b, c;
while (cin >> a >> b >> c){
istria(a, b, c);
}
return 0;
}
//使用字符串存储数据,然后写字符串相加函数,和比较的仿函数
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
#include <string>
struct Com
{
bool operator()(const string& str1,const string& str2) const
{
if(str1.size() < str2.size())
{
return true;
}
else if(str1.size() == str2.size())
{
for(size_t i = 0; i < str1.size(); i++)
{
if(str1[i] < str2[i])
{
return true;
}
else if(str1[i] > str2[i])
{
return false;
}
}
}
return false;
}
};
string Add(const string& str1,const string& str2)
{
//int Max = std::max(str1.size(),str2.size());
string res;
//res.reserve(Max + 1);
int index1 = str1.size() - 1;
int index2 = str2.size() - 1;
int sum = 0;
int add = 0;
while(index1 >= 0 && index2 >= 0)
{
int tmp = str1[index1] - '0' + str2[index2] - '0' + add;
sum = tmp % 10;
add = tmp / 10;
res += sum + '0';
index1--;
index2--;
}
//cout << res << endl;
while(index1 >= 0)
{
int tmp = str1[index1] - '0' + add;
sum = tmp % 10;
add = tmp / 10;
res += sum + '0';
index1--;
}
while(index2 >= 0)
{
int tmp = str2[index2] - '0' + add;
sum = tmp % 10;
add = tmp / 10;
res += sum + '0';
index2--;
}
//cout << res << endl;
if(add > 0)
{
res += add + '0';
}
reverse(res.begin(),res.end());
return res;
}
bool Judge(const vector<string>& v)
{
string add = Add(v[0],v[1]);
//cout << add << endl;
if(Com()(add,v[2]) || add == v[2])
{
return false;
}
return true;
}
int main()
{
vector<string> v(3);
while(cin >> v[0] >> v[1] >> v[2])
{
sort(v.begin(),v.end(),Com());
bool res = Judge(v);
if(res == true)
{
cout << "Yes" << endl;
}
else
{
cout << "No" << endl;
}
}
return 0;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
String a=scanner.next();
String b=scanner.next();
String c=scanner.next();
if (compare(addStr(a,b),c)&&compare(addStr(a,c),b)&&compare(addStr(b,c),a))
{
System.out.println("Yes ");
}
else
{
System.out.println("No ");
}
}
}
private static boolean compare(String s1,String s2)
{
if (s1.length()==s2.length())
{
if (s1.compareTo(s2)>0)
{
return true;
}
else
{
return false;
}
}
else
{
if (s1.length()>s2.length())
{
return true;
}
else
{
return false;
}
}
}
private static String addStr(String a, String b)
{
int i = a.length() - 1;
int j = b.length() - 1;
int carry = 0;
StringBuilder sb = new StringBuilder();
while (i >= 0 || j >= 0 || carry != 0)
{
int x = i >= 0 ? a.charAt(i) - '0' : 0;
int y = j >= 0 ? b.charAt(j) - '0' : 0;
int sum = x + y + carry;
sb.append(sum % 10);
carry = sum / 10;
i--;
j--;
}
return sb.reverse().toString();
} import java.util.*;
import java.math.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
BigDecimal a = sc.nextBigDecimal();
BigDecimal b = sc.nextBigDecimal();
BigDecimal c = sc.nextBigDecimal();
if(a.add(b).compareTo(c) > 0
&& a.add(c).compareTo(b) > 0
&&c.add(b).compareTo(a) > 0){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}
}