rt,
https://cses.fi/problemset/task/1662/
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int n;
long long a[200010];
long long maths[200010];
map<long long,long long> mp;
int main(){
cin>>n;
maths[0]=0;
for(int i=0;i<n;i++){
cin>>a[i];
maths[i+1]=maths[i]+a[i];
maths[i+1]%=n;
}
set<long long> s;
s.insert(0);
mp[0]++;
for(int i=1;i<=n;i++){
s.insert(maths[i]);
mp[maths[i]]++;
}
long long ans=0;
for(set<long long>::iterator it=s.begin();it!=s.end();it++){
ans+=mp[*it]*(mp[*it]-1)/2;
}
cout<<ans<<endl;
return 0;
}
布吉岛哪里错了,所以求助,谢谢!