Advertisement
leminhkt

noname14

Mar 3rd, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define FOR(i, a, b) for(int i=(a); i<=(b); i++)
  3. #define FORR(i, a, b) for(int i=(a); i>=(b); i--)
  4. #define sz(x) (x).size()
  5. using namespace std;
  6. int n, s, k;
  7. int main(){
  8.     cin>>n>>k;
  9.     deque<int> a(n), res, tam;
  10.     FOR(i, 0, n-1){
  11.         cin>>a[i];
  12.         s=0, tam.resize(0);
  13.         FORR(j, i, 0){
  14.             s+=a[j];
  15.             tam.push_front(a[j]);
  16.             if(s%k==0&&sz(tam)>sz(res)) res=tam;
  17.         }
  18.     }
  19.     for(int i:res) cout<<i;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement