Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define MAX 1000007
- using namespace std;
- long long arr[MAX], n;
- long long dp[MAX];
- int main(){
- scanf("%d", &n);
- for(int i = 0; i < n; i++) scanf("%d", &arr[i]);
- long long ans = 0, sum = 0;
- dp[0] = 1;
- for(int i = 0; i < n; i++){
- sum = (sum+arr[i])%8;// modulo que vc quer as combinações
- ans += dp[sum];
- dp[sum]++;
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment