multiplication

题目描述

给出6个非负整数A,B,C,D,E,F
比较 A*B*C 和 D*E*F 的大小
如果相等输出0
如果前者大于后者输出1
如果前者小于后者输出-1

输入

一行6个非负整数分别表示A,B,C,D,E,F,且都不超过10^7

输出

一行一个整数,表示答案。

样例输入

1 2 3 4 5 6

样例输出

-1

感觉应该是要高精度,没想到可以使用long long

#include <iostream>
#include <stdio.h>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
int main()
{
    ll a, b, c, d, e, f;
    while (~scanf("%lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &e, &f))
    {
        if (a * b * c == d * e * f)
            printf("0\n");
        else if (a * b * c > d * e * f)
            printf("1\n");
        else
            printf("-1\n");
    }
    return 0;
}
发布了145 篇原创文章 · 获赞 30 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_43984169/article/details/102545783