Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Righ answer on local machine but wrong answer on codeforces.

Правка en1, от ppastram, 2020-06-01 09:10:44

Hi everyone, I'm solving problem A from round #575 (div 3). It's a fairly simple problem and I'm getting the right answer when I try the example on visual studio code (using c++) but when I upload my solution, I get the third case wrong (the one with big numbers). Why can this happen?

Useful info: problem: https://codeforces.me/contest/1196/problem/A my code:

include

int main() { int n = 0; std::cin >> n;

for (int i = 0; i < n; i++)
{
    long total = 0;
    long a = 0;
    long b = 0;
    long c = 0;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    total = a+b+c;
    if (int(total)%2==0)
        std::cout<<total/2 <<"\n";
    else
        std::cout<<(total-1)/2 <<"\n";

}
return 0;

}

example entry: 4 1 3 4 1 10 100 10000000000000000 10000000000000000 10000000000000000 23 34 45 my output on vs code (right answer): 4 55 15000000000000000 51 my output when I submit my solution: 4 55 1073741823 0

Thank you very much for your help!

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский ppastram 2020-06-01 09:10:44 1171 Initial revision (published)