ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1068. Sum

Где ошибка? С++
Posted by NoNSoS 16 Jul 2015 12:49
#include <iostream>
using namespace std;

int main (){
    int a;
    int sum;
    cin >> a;
    if (a<1 && a>=-10000){
        for (int i = 1; i >= a; i--){
            sum = sum + i;

        };
    } else if (a>=1 && a<=10000) {
        for (int i = 1; i <= a; i++){
            sum = sum + i;

        };
    };
    cout << sum;
    return 0;
}

при: N(a) -- sum
10000 -- 50005000
1 -- 1
0 -- 1
-1 -- 0
-3 -- -5
-10000 -- 50004999

Edited by author 16.07.2015 12:55

Edited by author 16.07.2015 12:56