import std; struct trio { int I; int S; int T; } void main () { int N, Q; readln.read(N, Q); trio[] instruct = new trio[](Q); foreach (i; 0..Q) { with (instruct[i]) { readln.read(I, S, T); I--; } } solve(N, Q, instruct); } void solve (int N, int Q, trio[] instruct) { // 時間が全部配列に乗るので、imos的に「ある時間に演奏していた人数」を求めて、あとは累積和でおけw const int time = 10^^5+1; int[] PlayerCount = new int[](time); double[] score = new double[](time); score[] = 0; // imos foreach (i; instruct) { PlayerCount[i.S]++; PlayerCount[i.T]--; } foreach (i; 1..time) { PlayerCount[i] += PlayerCount[i-1]; } // 重みづけ foreach (i; 0..time) { if (PlayerCount[i] == 0) continue; score[i] = 1./PlayerCount[i]; } // 累積和 ( [0, i)の総和 ) double[] cum = new double[](time+1); cum[] = 0; foreach (i; 1..time+1) { cum[i] = cum[i-1] + score[i-1]; } // 各クエリから計算 double[] ans = new double[](N); ans[] = 0; foreach (i; instruct) { ans[i.I] += cum[i.T]-cum[i.S]; } // output foreach (a; ans) { writeln(format("%.10f", a)); } } void read(T...)(string S, ref T args) { auto buf = S.split; foreach (i, ref arg; args) { arg = buf[i].to!(typeof(arg)); } }