Problem Description
Now, we have a function f(x)=Ax2−Bsinx,A≥0,B≥0, here A and B are integer. We want to know minimum x satisfy f(x) = y, and x>=0.
Input
The first line in the input file is an Integer T(1≤T≤500).
The first line of each test case contains two integer A,B(0≤A,B≤103).
Then a line a integer y(−103≤y≤103).
Output
For each test case, output the minimum x. if no such x exists, output “error”.
The answer should accurate to five decimal places.
Sample Input
2
1 0
5
1 1
-2
Sample Output
2.23607
error
https://www.zybang.com/question/8bd1caed1688507caa22354de41c400f.html
有两种方法。
一个是全局发号器(例如ZooKeeper有Sequence型节点,或者自己弄个发号器服务不断产生递增值作为发号),但是效率会比较低。
二个是mapPartition,获得当前分区的分区号。然后分区号x一个系数+当前分区本地递增值。系数是分区最大的数据条数+一定冗余。
最省事是前者,最快但容易出问题是后者。