Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int n,x,sum1=0,sum2=0,sum3=0;
- cin>>n;
- // for(int i=0;i<n;i++)
- // {
- // cin>>x;
- // if(x%10==5 && x%3==0)
- // sum1=sum1+x;
- // if(x%10==2 && x%3==0)
- // sum2=sum2+x;
- // if ( !((x%10==5 && x%3==0)||(x%10==2 && x%3==0)) )
- // sum3 += x;
- // }
- for (int i = 0; i < n; i ++) {
- cin >> x;
- bool f = 0;
- if (x % 10 == 5 || x % 3 == 0) {
- f = 1;
- sum1 += x;
- }
- if (x % 10 == 2 || x % 3 == 0) {
- f = 1;
- sum2 += x;
- }
- if (!f) sum3 += x;
- }
- cout<<sum1<<" "<<sum2<<" "<<sum3;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement