Information
- ID
- 1549
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 172
- Accepted
- 43
- Uploaded By
龟速乘
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
long long c,sum = 0;
cin>>n>>c;
long long a[n];
for(int i = 0 ; i < n ; i++){
cin>>a[i];
a[i] %= c;
}
for(int i = 1 ; i < n ; i++){
while(a[i] > 0){
if(a[i] & 1){
sum = (sum % c + a[0] % c) % c;
}
a[0] = (a[0] % c + a[0] % c) % c;
a[i] = a[i] / 2;
}
a[0] = sum;
sum = 0;
}
cout<<a[0]<<endl;
return 0;
}
By signing up a 追梦算法网 universal account, you can submit code and join discussions in all online judging services provided by us.