标签:
Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 350 Accepted Submission(s): 148
#include <iostream> #include <stdio.h> #include <math.h> #include <stdlib.h> #include <algorithm> #include <string.h> using namespace std; const int N = 2005; int v[N]; int n; int main() { while(scanf("%d",&n)!=EOF){ for(int i=0;i<=2*n-2;i++){ scanf("%d",&v[i]); } int q; int temp=0; long long ans = 0; scanf("%d",&q); while(q--){ int r,c; scanf("%d%d",&r,&c); r = (r+temp)%n,c = (c+temp)%n; temp = 0; for(int i=0;i<n;i++){ temp+= v[n-1+i-r]*v[n-1+c-i]; } ans += temp; } printf("%lld\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5657791.html