- #include <bits/stdc++.h>
- using namespace std;
- #define llu long long unsigned
- long long mod_pow(long long b, long long e, long long m) {
- long long ans = 1;
- while (e > 0) {
- if (e & 1)
- ans = (ans * b) % m;
- b = (b * b) % m;
- e >>= 1;
- }
- return ans;
- }
- int main(){
- int ts;
- scanf("%d", &ts);
- for(int p = 1; p <= ts; p++){
- llu sum = 0, n, k, m;
- scanf("%llu%llu%llu",&n, &k, &m);
- for(llu i =0; i <n; i++){
- llu a;
- scanf("%llu", &a);
- sum+= a;
- }
- llu ans = k;
- ans = (ans*(mod_pow(n, k-1, m)))%m;
- //cout<<"ans = "<<sum<<endl;
- ans = (ans*sum)%m;
- printf("Case %d: %llu\n",p, ans);
- }
- return 0;
- }
Saturday 29 July 2017
Lightoj 1213 - Fantasy of a Summation
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...
-
Problem link: Problem Analysis: It is actually a basic Bisection problem , as we can see here we can not actually find a formula fo...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
No comments:
Post a Comment