Soldier Kill (V) time limit: -Ms | Memory Limit:65535KB Difficulty:5
-
-
Describe
-
South generals have millions of troops, now known to have a total of M soldiers, numbered 0~m, each time there is a task, there will always be a number of people together Qingzhan (numbers close to each other often in a piece, familiar with each other), eventually they get the military exploit, also would be divided into everyone, so, sometimes, It is difficult to calculate how many military exploit they have.
Under such circumstances, the general of South will often after many battles to ask the military commander of the Soldier No. I to the total number of soldiers of the J number military exploit.
Please help the advisers to answer the questions of the South General.
-
-
Input
-
-
only one set of test data
The first line is a three integer n,c,q (1<=n,c,q<=1000000), where N represents the total number of soldiers.
The subsequent line C, with three integers per line, Mi,ni,ai (0<=mi<=ni<=n,0<=ai<=100), indicates an average increase in Ai military exploit from the number of soldiers from Mi to Ni.
After the Q line, there are two positive positive m,n per line, indicating that the South general is inquiring about the number M to Soldier No. N.
-
-
Output
-
-
Please output the total number of military exploit for each query to the Soldier No. N, as this value may be too large, please output the result to 10003
-
-
Sample input
-
-
5 3 21 3 22 4 15 5 101 52 3
-
-
Sample output
-
-
196
-
-
#include <stdio.h> #include <string.h>const int N = 1e6+5;int S[n];int main () {int n,m,q,i;scanf ("%d%d%d", &am P;N,&M,&Q); while (m--) {int x,y,z;scanf ("%d%d%d", &x,&y,&z); s[x]=s[x]+z;s[y+1]=s[y+1]-z;} for (i=1;i<=n;i++) {s[i]=s[i]+s[i-1]; After the operation, each soldier's exploits are}for (i=1;i<=n;i++) {s[i]= (s[i]+s[i-1])%10003; Get the prefix and}while (q--) {int a,b;scanf ("%d%d", &a,&b);p rintf ("%d\n", (s[b]-s[a-1]+10003)%10003);} return 0;}
NY 228 Soldier Kills (v)--God's question, slowly understand