Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin>>t;
- while(t--){
- int n;
- cin>>n;
- vector<int> a(n);
- for(auto &e: a) cin>>e;
- int tot = accumulate(a.begin(), a.end(), 0);
- int ans = (3 - tot%3)%3;
- int one=0, two=0;
- for(auto e: a)
- {
- one += (e%3 == 1);
- two += (e%3 == 2);
- }
- if(tot%3==1 && one) ans = min(ans, 1);
- if(tot%3==2 && two) ans = min(ans, 1);
- cout<<ans<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement