标签:turn images panel lease XA mod AC The nes
描述
Given n positive numbers a1, a2, ..., an,two number m and b,please calculate the following expression:
Here "x mod y" is the positive remainder when x is divided by y. For example, 3 mod 7 = 3
输入
There are multiple test cases. Each teat case has two lines, the first line contains three positve integers n, m and b, the second line has n positive integers
a1, a2, ..., an a integer n, all positve numbers in this problem are not larger than 1000.
The end of input is marked by end of file.
输出
For each input, you should calculate value of the expression and output it.
样例输入
1 1 2
1
3 2 5
2 2 2
样例输出
1
2
#include<bits/stdc++.h> using namespace std; int main() { int n,m,b,i,j,a[1005]; //cifang-m mod-b while(scanf("%d%d%d",&n,&m,&b)!=EOF) { long long s=0; for(i=0;i<n;i++) { scanf("%d",&a[i]); long long x=1; for(j=1;j<=m;j++) { x=x*a[i]; if(x>=b) x=x%b; } s=s+x; if(s>=b) s=s%b; } printf("%lld\n",s); } return 0; }
标签:turn images panel lease XA mod AC The nes
原文地址:https://www.cnblogs.com/kannyi/p/8996444.html