UVa 10025 - The ? 1 ? 2 ? ... ? n = k problem
2010-03-03 19:58
393 查看
/* coder: ACboy date: 2010-3-3 result: AC description: UVa 10025 - The ? 1 ? 2 ? ... ? n = k problem */ #include <iostream> using namespace std; int main() { int k; int n; #ifndef ONLINE_JUDGE freopen("10025.txt", "r", stdin); #endif cin >> n; while (n--) { int temp; int i; cin >> k; if (k < 0) k = -k; for (i = 1; ;i++) { temp = (i + 1) * i / 2; if (temp >= k) break; } if (temp == k || (temp - k) % 2 == 0) cout << i << endl; else { int ok = 0; while (!ok) { i++; temp += i; //cout << " i = " << i << " temp = " << temp << endl; if ((temp - k) % 2 == 0) break; } cout << i << endl; } if (n > 0) cout << endl; } return 0; }
相关文章推荐
- uva 10025 The ? 1 ? 2 ? ... ? n = k problem(算式规律)
- UVa 10025 - The ? 1 ? 2 ? ... ? n = k problem
- UVa 10025 The ? 1 ? 2 ? ... ? n = k problem
- UVA - 10025 The ? 1 ? 2 ? ... ? n = k problem
- Uva 10025 - The ? 1 ? 2 ? ... ? n = k problem
- UVa 10025 - The ? 1 ? 2 ? ... ? n = k problem
- UVa 10025 - The ? 1 ? 2 ? ... ? n = k problem
- uva 10025 The ? 1 ? 2 ? ... ? n = k problem
- UVA - 10025 The ? 1 ? 2 ? ... ? n = k problem
- UVA 10025 The ? 1 ? 2 ? ... ? n = k problem
- UVA - 10025 The ? 1 ? 2 ? ... ? n = k problem
- UVA - 10025 The ? 1 ? 2 ? ... ? n = k problem
- UVa - 10025 - The ? 1 ? 2 ? ... ? n = k problem
- uva 10025 - The ? 1 ? 2 ? ... ? n = k problem
- The ? 1 ? 2 ? ... ? n = k problem uva 10025
- uva_10025 - The ? 1 ? 2 ? ... ? n = k problem
- Uva 10025 - The ? 1 ? 2 ? ... ? n = k problem
- uva 10025 The ? 1 ? 2 ? ... ? n = k problem
- uva 10025 - The ? 1 ? 2 ? ... ? n = k problem
- UVa 10025 The ? 1 ? 2 ? ... ? n = k problem