- #include <bits/stdc++.h>
- using namespace std;
- int dp[100005];
- int main()
- {
- int ts;
- cin>>ts;
- for(int h = 1; h <= ts; h++){
- long long int n, sum= 0, ans = 0, k;
- cin>>n>>k;
- memset(dp, 0, sizeof(dp));
- dp[0] = 1;
- for(int i = 0; i <n; i++){
- int a;
- cin>>a;
- ans+= dp[(sum+a)%k];
- sum = (sum+a)%k;
- dp[sum]++;
- }
- cout<<"Case "<<h<<": "<<ans<<endl;
- }
- return 0;
- }
Thursday, 27 July 2017
Lightoj 1134 - Be Efficient
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
-
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
No comments:
Post a Comment