Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std ;
- #define ll long long
- ll lcm(ll a, ll b)
- {
- return a/__gcd(a,b) *b;
- }
- int main ()
- {
- int t;
- scanf("%d",&t);
- int a[3000];
- while (t--)
- {
- int n ;
- scanf("%d",&n);
- for (int i =0 ; i <n ; i ++)
- {
- scanf("%d",a+i);
- }
- int ans =0 ;
- for (int i =0 ; i < n ; i ++ )
- {
- ll sum =0 ;
- ll tot_lcm = 1;
- for (int j =i ; j< n ; j++)
- {
- sum += a[j];
- tot_lcm = lcm(tot_lcm, a[j]);
- if( tot_lcm > (1ll<<30)*(n-i) )
- break;
- ans += (sum % tot_lcm == 0);
- }
- }
- printf("%d\n",ans );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement