Now I give my proof.
notice that $$$\sin(x)\sin(y)=\frac{1}{2}(cos(x-y)-cos(x+y))$$$
inverse $$$\sin(x)\sin(y)=\frac{1}{2}(cos(x-y)-cos(x+y))$$$ to be $$$\cos(a)-\cos(b)=-2\sin(\frac{a+b}2)\sin(\frac{a-b}2)$$$
maybe a nice idea! What do u think?
# | User | Rating |
---|---|---|
1 | ecnerwala | 3649 |
2 | Benq | 3581 |
3 | orzdevinwang | 3570 |
4 | Geothermal | 3569 |
4 | cnnfls_csy | 3569 |
6 | tourist | 3565 |
7 | maroonrk | 3531 |
8 | Radewoosh | 3521 |
9 | Um_nik | 3482 |
10 | jiangly | 3468 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 162 |
4 | TheScrasse | 159 |
5 | nor | 158 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 151 |
8 | SecondThread | 147 |
9 | orz | 146 |
10 | pajenegod | 145 |
Now I give my proof.
notice that $$$\sin(x)\sin(y)=\frac{1}{2}(cos(x-y)-cos(x+y))$$$
inverse $$$\sin(x)\sin(y)=\frac{1}{2}(cos(x-y)-cos(x+y))$$$ to be $$$\cos(a)-\cos(b)=-2\sin(\frac{a+b}2)\sin(\frac{a-b}2)$$$
maybe a nice idea! What do u think?
have a look at this code of 1565E which got runtime error and idk why, so I have to write again in C++ during the competition.
I'll appreciate if somebudy could do me a favor :)
import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def rdvec():
return [int(i) for i in input().split()]
def rd():
return int(input())
T=int(input())
def solve():
n=rd()
g=[[] for i in range(n)]
U=[0]*n
for i in range(n-1):
x,y=rdvec()
x-=1
y-=1
g[x].append(y)
g[y].append(x)
U[x]+=1
U[y]+=1
def dfs(x,fa,s):
if s%2==0:
U[x]=-U[x]
for y in g[x]:
if y!=fa:
dfs(y,x,s+1)
dfs(0,0,0)
print(*U)
for o in range(T):
solve()
Name |
---|