Codeforces 1189C Candies!
发布时间:2020-12-16 07:19:50 所属栏目:百科 来源:网络整理
导读:题目链接:http://codeforces.com/problemset/problem/1189/C 思路:前缀和。 AC代码: #includebits/stdc++.h using namespace std; const int maxn = 1e5 + 5 ; int a[maxn]; int n,m; int ask( int x, int y){ return (a[y] - a[x- 1 ])/ 10 ;} int main(
题目链接:http://codeforces.com/problemset/problem/1189/C 思路:前缀和。 AC代码: #include<bits/stdc++.h> using namespace std; const int maxn = 1e5 +5; int a[maxn]; int n,m; int ask(int x,int y) { return (a[y] - a[x-1])/10; } int main() { cin >> n; int x,y; for(int i = 1;i <= n;i++) { cin >> a[i]; a[i] += a[i-1]; } cin >> m; while(m--) { cin >> x >> y; cout << ask(x,y) << endl; } return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |