Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define FOR(i, a, b) for(int i=(a); i<=(b); i++)
- #define FORR(i, a, b) for(int i=(a); i>=(b); i--)
- #define sz(x) (x).size()
- using namespace std;
- int n, s, k;
- int main(){
- cin>>n>>k;
- deque<int> a(n), res, tam;
- FOR(i, 0, n-1){
- cin>>a[i];
- s=0, tam.resize(0);
- FORR(j, i, 0){
- s+=a[j];
- tam.push_front(a[j]);
- if(s%k==0&&sz(tam)>sz(res)) res=tam;
- }
- }
- for(int i:res) cout<<i;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement