Problem: Contest Page | CodeChef
DIFFICULTY:
EASY.
PROBLEM:
The chef is having one array of natural numbers. Cheffina challenges chef that find the sum of weights all the natural numbers present in the array, but the main problem is that all numbers have not original weights. After every 6 natural numbers weight is set to 1 as weight increases by 1 after that. (i.e. weight of 1 is 1, weight of 2 is 2 but the weight of 7 is 1 and weight of 8 is 2 and so on…). Help the chef to find the sum.
Program:
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t,x,n;
cin>>t;
while(t--){
cin>>n;
long long ans=0;
for(int i=0;i<n;i++){
cin>>x;
if(x%6==0)ans+=6;
else ans+=x%6;
}
cout<<ans<<endl;
}
}