#1033. 【入门4】开灯
【入门4】开灯
说明
在一条无限长的路上,有一排无限长的路灯,编号为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo separator="true">,</mo><mn>2</mn><mo separator="true">,</mo><mn>3</mn><mo separator="true">,</mo><mn>4</mn><mo separator="true">,</mo><mo>…</mo></mrow></semantics></math>1,2,3,4,…。
每一盏灯只有两种可能的状态,开或者关。如果按一下某一盏灯的开关,那么这盏灯的状态将发生改变。如果原来是开,将变成关。如果原来是关,将变成开。
在刚开始的时候,所有的灯都是关的。小明每次可以进行如下的操作:
指定两个数,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo separator="true">,</mo><mi>�</mi></mrow></semantics></math>a,t(<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>a 为实数,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>t 为正整数)。将编号为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌊</mo><mi>�</mi><mo stretchy="false">⌋</mo><mo separator="true">,</mo><mo stretchy="false">⌊</mo><mn>2</mn><mo>×</mo><mi>�</mi><mo stretchy="false">⌋</mo><mo separator="true">,</mo><mo stretchy="false">⌊</mo><mn>3</mn><mo>×</mo><mi>�</mi><mo stretchy="false">⌋</mo><mo separator="true">,</mo><mo>…</mo><mo separator="true">,</mo><mo stretchy="false">⌊</mo><mi>�</mi><mo>×</mo><mi>�</mi><mo stretchy="false">⌋</mo></mrow></semantics></math>⌊a⌋,⌊2×a⌋,⌊3×a⌋,…,⌊t×a⌋ 的灯的开关各按一次。其中 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌊</mo><mi>�</mi><mo stretchy="false">⌋</mo></mrow></semantics></math>⌊k⌋ 表示实数 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>k 的整数部分。
在小明进行了 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>n 次操作后,小明突然发现,这个时候只有一盏灯是开的,小明很想知道这盏灯的编号,可是这盏灯离小明太远了,小明看不清编号是多少。
幸好,小明还记得之前的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>n 次操作。于是小明找到了你,你能帮他计算出这盏开着的灯的编号吗?
输入格式
第一行一个正整数 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>n,表示 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>n 次操作。
接下来有 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>n 行,每行两个数,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub><mo separator="true">,</mo><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>ai,ti。其中 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>ai 是实数,小数点后一定有 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>6</mn></mrow></semantics></math>6 位,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>ti 是正整数
输出格式
仅一个正整数,那盏开着的灯的编号样例
3
1.618034 13
2.618034 7
1.000000 21
20
提示
记 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo>=</mo><msubsup><mo>∑</mo><mrow><mi>�</mi><mo>=</mo><mn>1</mn></mrow><mi>�</mi></msubsup><msub><mi>�</mi><mi>�</mi></msub><mo>=</mo><msub><mi>�</mi><mn>1</mn></msub><mo>+</mo><msub><mi>�</mi><mn>2</mn></msub><mo>+</mo><msub><mi>�</mi><mn>3</mn></msub><mo>+</mo><mo>⋯</mo><mo>+</mo><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>T=i=1∑nti=t1+t2+t3+⋯+tn。
- 对于 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>100</mn><mi mathvariant="normal">%</mi></mrow></semantics></math>100% 的数据,满足 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo>≤</mo><mn>2000000</mn></mrow></semantics></math>T≤2000000, <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo>≤</mo><mn>5000</mn></mrow></semantics></math>n≤5000,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><msub><mi>�</mi><mi>�</mi></msub><mo><</mo><mn>1000</mn></mrow></semantics></math>1≤ai<1000,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><msub><mi>�</mi><mi>�</mi></msub><mo>≤</mo><mi>�</mi></mrow></semantics></math>1≤ti≤T。
数据保证,在经过 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>n 次操作后,有且只有一盏灯是开的,不必判错。而且对于所有的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i 来说,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub><mo>×</mo><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>ti×ai 的最大值不超过 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2000000</mn></mrow></semantics></math>2000000。