Coderloop not accepting Project Euler solution
I discovered this website where you submit your solution and the "puzzle master" processes it and verifies it. I have two solutions, both of which work fine on my compiler and yet the "puzzle master" is rejecting them.
Solution 1: Brute Force
#include <iostream>
using namespace std;
int main()
{
int s=0,i;
for(i=1;i<1000;i++)
if(i%3==0 || i%5==0)
s=s+i;
cout<<s<<endl;
return 0;
}
Error:
'g++ -lm -lcrypt -O2 -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -DUNIV_LINUX -DUNIV_LINUX -Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient euler1.cc -o euler1
euler1.cc:14: error: expected class-name at end of input
make: *** [all] Error 1'
Solution 2: Using closed form
#include <iostream>
using namespace std;
int main()
{
int k=1000, j=1000/3,l=1000/5,m=1000/15;
k=3*(j*(j+1)/2)+5*(l*(l-1)/2)-15*(m*(m+1)/2);
cout<<k<<endl;
return 0;
}
Error:
g++ -lm -lcrypt -O2 -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -DUNIV_LINUX -DUNIV_LINUX -Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient euler1.cc -o euler1
2.euler1.cc:15: error: expected class-name before â~â token
3.make: *开发者_开发问答** [all] Error 1
Are these errors caused by my code, or the website?
If you submitted your code using the online editor, I guess it simply did not compile.
Indeed the online editor allows submissions only for interpreted languages, whereas compiled languages must be provided via file upload, along with a Makefile or an Ant file that indicates the judge how to compile it.
It is a bit confusing indeed that the online editor allows you to choose syntax coloring for languages such as C++ and Java, although submitting the resulting code will fail in all cases.
精彩评论