TopCoder High School SRM 17 Level one - 250 pt - BiSquare Sums editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm17
TopCoder High School SRM 17 Level one - 250 pt - BiSquare Sums solution:
#include <iostream> using namespace std; class BisquareSums { public: int getSums(int lo, int hi) { int a[105]={0}, cnt=0; for(int i=0; i<10; i++) { for(int j=0; j<10; j++) { a[i*i + j*j]++; } } for(int i=lo; i<=hi; i++) if(a[i]) cnt++; return cnt; } };
note: constraints are low, so just do it - nike ;)
No comments:
Post a Comment