Sines Sum Queries
All submissions for this problem are available.
You are given a sequence of integers A0, A1, ..., AN-1. Initially Ai=i for all i. You need to perform some strange queries with it. Each query has the form "L R D" where 0 <= L <= R < N and D is an integer. If D=0 then you need to find the sum of sines of the numbers AL, AL+1, ..., AR that is sin AL + ... + sin AR. Otherwise you need to add D to the numbers AL, AL+1, ..., AR.
The first line contains two positive integers N and Q. Here, N <= 109 is the length of the initial sequence and Q <= 100000 is the number of queries you need to perform with it. The next Q lines describe queries, one per line. The i'th such line contains three integers L, R and D. Here 0 <= L <= R < N and -10000 <= D <= 10000.
The output consists of answers for all queries where D=0. For each such query you must produce a line with the corresponding sines sum. Answers within an absolute error of 10-6 will be accepted.
Input: 5 6 0 4 0 0 2 1 3 4 2 0 4 0 2 3 -1 1 4 0 Output: 1.1350859 0.65354865 0.782376860
|Tags||anton_lunyov, cook11, hard|
|Time Limit:||1.23584 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.