3 solutions
- 
  1
龟速乘
#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; } 
Information
- ID
 - 1549
 - Time
 - 1000ms
 - Memory
 - 256MiB
 - Difficulty
 - 7
 - Tags
 - # Submissions
 - 172
 - Accepted
 - 43
 - Uploaded By