Advertisement
Saleh127

cf 1374D

Sep 27th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13.  
  14. ll n,k,c,d,e,f,i,j;
  15. map<ll,ll>a;
  16. cin>>n>>k;
  17. for(i=0; i<n; i++)
  18. {
  19. cin>>c;
  20. d=c%k;
  21. if(d==0) continue;
  22. a[k-d]++;
  23. }
  24. j=0;
  25. for(auto z: a)
  26. {
  27. c=z.first;
  28. d=z.second;
  29. f=(d-1)*k+c;
  30. j=max(j,f+1);
  31. }
  32. cout<<j<<endl;
  33. }
  34.  
  35.  
  36. return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement