This is an online judge problem of which the link is https://pintia.cn/problem-sets/994805342720868352/problems/994805406352654336.
The compiler I choose is g++.
the input range:
a, b and c in [−263,263 ]
t <= 10
#include <bits/stdc++.h>
using namespace std;
int main()
{
//freopen("in.txt", "r", stdin);
int t, tcase = 1;
scanf("%d", &t);
while(t--)
{
long long a, b, c;
//there is an error here when replacing scanf with cin
//scanf("%lld %lld %lld", &a, &b, &c);
cin >> a >> b >> c;
long long res = a + b;
bool flag;
if(a < 0 && b < 0 && res >= 0)flag = false;
else if(a > 0 && b > 0 && res < 0)flag = true;
else if(a + b > c)flag = true;
else flag = false;
if(flag == true)
{
printf("Case #%d: true\n", tcase++);
}
else
{
printf("Case #%d: false\n", tcase++);
}
}
return 0;
}
Sometimes I use scanf
, the program runs correctly, but when replacing it with cin
, I get the wrong answer. This is an online judge problem, so I am sorry that I can not give the test data and the output information. Please tell me what is the problem, thank you very much.
Aucun commentaire:
Enregistrer un commentaire