CF1735A.Working Week

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Your working week consists of nn days numbered from 11 to nn , after day nn goes day 11 again. And 33 of them are days off. One of the days off is the last day, day nn . You have to decide when the other two are.

Choosing days off, you pursue two goals:

  • No two days should go one after the other. Note that you can't make day 11 a day off because it follows day nn .
  • Working segments framed by days off should be as dissimilar as possible in duration. More specifically, if the segments are of size l1l_1 , l2l_2 , and l3l_3 days long, you want to maximize min(l1l2,l2l3,l3l1)\min(|l_1 - l_2|, |l_2 - l_3|, |l_3 - l_1|) .

Output the maximum value of min(l1l2,l2l3,l3l1)\min(|l_1 - l_2|, |l_2 - l_3|, |l_3 - l_1|) that can be obtained.

输入格式

The first line of the input contains a single integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. The description of test cases follows.

The only line of each test case contains the integer nn ( 6n1096 \le n \le 10^9 ).

输出格式

For each test case, output one integer — the maximum possible obtained value.

输入输出样例

  • 输入#1

    3
    6
    10
    1033

    输出#1

    0
    1
    342

说明/提示

In the image below you can see the example solutions for the first two test cases. Chosen days off are shown in purple. Working segments are underlined in green.

In test case 11 , the only options for days off are days 22 , 33 , and 44 (because 11 and 55 are next to day nn ). So the only way to place them without selecting neighboring days is to choose days 22 and 44 . Thus, l1=l2=l3=1l_1 = l_2 = l_3 = 1 , and the answer min(l1l2,l2l3,l3l1)=0\min(|l_1 - l_2|, |l_2 - l_3|, |l_3 - l_1|) = 0 .

For test case 22 , one possible way to choose days off is shown. The working segments have the lengths of 22 , 11 , and 44 days. So the minimum difference is 1=min(1,3,2)=min(21,14,42)1 = \min(1, 3, 2) = \min(|2 - 1|, |1 - 4|, |4 - 2|) . It can be shown that there is no way to make it larger.

首页