NYOJ 228 士兵杀敌(五)
2012-09-05 12:17
253 查看
http://acm.nyist.net/JudgeOnline/problem.php?pid=228
本想用树状数组的, 结果有点囧...........
然后看了别的大牛的做法.... 离线查询的可以有o(n)的算法...
View Code
本想用树状数组的, 结果有点囧...........
然后看了别的大牛的做法.... 离线查询的可以有o(n)的算法...
View Code
#include <iostream> #include <stdio.h> using namespace std; const int maxn = 1000005; const int M = 10003; int ans[maxn]; int main() { int n, m, q, a, b, c, i; scanf("%d%d%d",&n,&m,&q); while(m--) { scanf("%d%d%d",&a,&b,&c); ans[a]+=c; ans[b+1]-=c; } for(i=1; i<=n; i++) ans[i] += ans[i-1]; for(i=1; i<=n; i++) ans[i]=(ans[i-1]+ans[i])%M; while(q--) { scanf("%d%d",&a,&b); printf("%d\n",(ans[b]-ans[a-1]+M)%M); } return 0; }
相关文章推荐
- NYOj-228-士兵杀敌(五)
- nyoj 228 士兵杀敌(五)
- NYOJ 228 士兵杀敌系列
- nyoj 228 士兵杀敌(五)
- NYOJ 228 士兵杀敌系列
- nyoj228 士兵杀敌(五) (数组)
- nyoj 228 士兵杀敌(五)
- nyoj228 士兵杀敌(5)插线问线
- nyoj228 士兵杀敌(五)(区间更新,区间查询)
- nyoj 士兵杀敌(五) 228 (数组灵活运用) 好题
- nyoj 228 士兵杀敌(五)
- NYOJ 228 士兵杀敌(五)
- nyoj 228 士兵杀敌(五)
- NYOJ 228 士兵杀敌五(插线问线__离线版)
- nyoj228 士兵杀敌五(数组的巧妙运用)
- NYOJ 228 士兵杀敌(五)
- nyoj 228 士兵杀敌(五)
- NYOJ228 士兵杀敌(五)(思路)
- NYOJ 228 士兵杀敌(五)
- NYOJ 228 士兵杀敌(五)(数组灵活运用)