http://codeforces.com/contest/103/problem/D

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define faster ios::sync_with_stdio(0);cin.tie(0) inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} /********************************************************************/ const int maxn = 3e5+;
ll n, m;
ll a[maxn];
ll cx[maxn], cy[maxn];
int kiss = ;
vector<int> d[];
ll dp[maxn];
ll ans[maxn]; int main(){
n = read();
for(int i = ;i <= n;i++)
a[i] = read();
m = read();
for(int i = ;i <= m;i++){
cx[i] = read(), cy[i] = read();
if(cy[i] < kiss)
d[cy[i]].push_back(i);
else{
ll ans1 = ;
for(int j = cx[i];j <= n;j += cy[i]){
ans1 += a[j];
}
ans[i] = ans1;
}
}
for(int i= ;i < kiss;i++){
if(d[i].size()){
for(int j = n;j;j--){ //From the back forward
if(j+i > n)
dp[j] = a[j];
else
dp[j] = dp[j+i] + a[j];
}
for(int j = ;j < d[i].size();j++)
ans[d[i][j]] = dp[cx[d[i][j]]];
}
}
for(int i = ;i <= m;i++)
cout << ans[i] << endl;
return ;
}

最新文章

  1. Notes: DOM Range
  2. iOS 隐藏键盘的几种常见方法
  3. python3爬虫再探之EXCEL(续)
  4. php简单计数器程序(文本计数器、图形计数器)
  5. dedecms 在php7.0无法安装
  6. linux系统文件夹的作用 good
  7. 自定义AccessDeniedHandler
  8. python3中的进程
  9. oo第二单元的自白
  10. hadoop/hdfs/yarn 详细命令搬运
  11. hive 创建orc表
  12. js的语言的理解
  13. gitlab自动备份恢复与卸载
  14. win7下docker环境centos容器中安装mysql5.7
  15. Linux知识(6)----VIM
  16. MFC进度条刷新处理
  17. php小练习——实现几种不同的金字塔
  18. Spring项目的发展历史和SpringBoot的发展历史
  19. C# LINQ(3)
  20. hadoop遇到的问题(汇总)

热门文章

  1. MongoDB 学习五:索引
  2. matlab面向对象设计---类的概念和使用
  3. jquery特效(2)—选项卡
  4. 数据结构之 图论---最小生成树(prim + kruskal)
  5. C#入门---2、C#装备知识(C#创建桌面程序的时候创建的是什么应用程序)
  6. Local storage htm5
  7. Rsync+Inotify同步
  8. BZOJ_2901_矩阵求和_前缀和
  9. JavaScript实现Select选择本周、上周、本季、上季、本年的时间选取
  10. Java字符串理解