f467. 10025 - The ? 1 ? 2 ? ... ? n = k problem
標籤 : CPE UVA math
通過比率 : 40人/49人 ( 82% ) [非即時]
評分方式:
Tolerant

最近更新 : 2020-12-11 19:38

內容

?1?2? . . .?n = k ?可填入'+'或'-'給K問N最小可以是多少

Given the following formula, one can set operators ‘+’ or ‘-’ instead of each ‘?’, in order to obtain a given k
?1?2? . . .?n = k
For example: to obtain k = 12, the expression to be used will be:
- 1 + 2 + 3 + 4 + 5 + 6 - 7 = 12
with n = 7

輸入說明

第一行有個T代表測資數
接下來T行會有個K(0 ≤ |k| ≤ 1000000000)

The first line is the number of test cases.
Each test case of the input contains an integer k (0 ≤ |k| ≤ 1000000000).

輸出說明

輸出一個貌似答案的數字

For each test case, your program should print the minimal possible n (1 ≤ n) to obtain k with the above formula.

範例輸入 #1
2
12
-3646397
範例輸出 #1
7
2701
測資資訊:
記憶體限制: 512 MB
公開 測資點#0 (20%): 1.0s , <1M
公開 測資點#1 (20%): 1.0s , <1M
公開 測資點#2 (20%): 1.0s , <1M
公開 測資點#3 (20%): 1.0s , <1M
公開 測資點#4 (20%): 1.0s , <1M
提示 :

2016 5月CPE第六題

2020/12/11 加強測資 感謝SUNGOD 

標籤:
CPE UVA math
出處:
UVA10025 [管理者: DE45A (一葉之秋) ]

本題狀況 本題討論 排行

編號 身分 題目 主題 人氣 發表日期
26282 liu76214@gma ... (Andrew liu) f467
UVa題目的輸出
362 2021-07-30 14:41
23684 SUNGOD (黑龍炎使.煞氣ㄟSUNGOD) f467
可加強測資
610 2020-12-08 21:33
23665 wj654cj86 (屠屠) f467
解題方向
663 2020-12-07 15:49