编程介的小学生 2020-05-27 18:32 采纳率: 20.5%
浏览 57
已结题

Colorful World 的算法

Recently little F buys 2n lights and aligns them in a circle at his beautiful garden. On the first day, when night falls, little F lights up the lights with 2n different colors, and his girlfriend is lost in the dreamy scene.

On the next 2n-1 days, little F turns the colors of lights counter-clockwise once every day in order to please his girlfriend with different scene. Let’s say on the first day little F lights up the i-th (starts from 1) light with color ci, then on the second day, the i-th light’s color becomes ci+1 and (2n)-th light’s color becomes c1. On the other side, every light has certain brightness, i.e., no matter what color the light is, its brightness will never change.

On the k-th (starts from 1) day his girlfriend can get hk happiness. On the (2n+1)-th day, the scene is as same as the one on the first day and h2n+1 is equal to h1. Little F stops the lights show and quickly realizes that his girlfriend has various preferences over different colors. For color cj, if her likeness is aj, then it will give (aj∙bi) happiness if the brightness of the i-th light, with color cj, is bi. Finally hk equals to the sum of happiness of all the lights on the k-th day.

Little F has already recorded bj for each color cj and hk on each day. He wants to calculate ai, thus he can find better ways to please his girlfriend in the future. It’s guaranteed that for the given input, there is only one solution to ai.

输入
The first line contains an integer T (1 ≤ T ≤ 20) -- the number of test cases.

For each test case:
The first line contains an integer n. 1 ≤ n ≤ 10.
The second line contains 2n integers, indicate b1, b2, ... , b2n. 0 ≤ b ≤ 5 000.
The third line contains 2n integers, indicate h1, h2, ... , h2n. 0 ≤ h ≤ 5 000.
输出
For each test case, you should output 2n real integer a1, a2, ... , a2n in order, separated by a single space in a single line. Each number should be rounded to 2 digits after the decimal point.
样例输入
1
1
8 10
4 9
样例输出
1.61 -0.89

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 matlab有关常微分方程的问题求解决
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?
    • ¥100 求三轴之间相互配合画圆以及直线的算法