TopCoder High School SRM 25 Level one - 250 pt - Many Numbers editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm25
TopCoder High School SRM 25 Level one - 250 pt - Many Numbers solution:
#include <iostream> #include <vector> #include <cmath> using namespace std; class ManyNumbers { public: int getSums(vector <int> n, int k) { int a=0, b=0; for(int i=0; i<n.size(); i++) { if(n[i]%k==0) a+=n[i]; else b+=n[i]; } return abs(a-b); } };
No comments:
Post a Comment