|
|
back to boardCrash #9 Could someone explain me why I've got Crash #9? I was trying all tests here but I've got nothing. #include <iostream> #include <fstream> #include <algorithm> using namespace std; int n, a[111111], b[111111], i, l = 0, sum, index = 1; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif cin >> n; for(i=1;i<=100000;i++) { a[i] = a[i-1] + i; } while(true) { sum = a[index] - a[l] + l; if(sum == n) { int e = index - l + 1; if(l == 0) l++, e--; cout << l << " " << e; return 0; } if(sum > n) { l++; } else { index++; } } return 0; } Edited by author 05.06.2011 21:10 |
|
|