Guest User

Szervusz, carlcolt!

a guest
Jan 12th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. /* test.cpp */
  2. #include <iostream>
  3. template <unsigned long N> struct Sum { enum { value = ((N%3)&&(N%5)?0:N) + Sum<N - 1>::value };};
  4. template <> struct Sum<0> { enum { value = 0 };};
  5. int main(){
  6.   for(unsigned int j=0;j<10000;j++){
  7.     unsigned long int x = Sum<10000>::value;
  8.     std::cout<<x<<"\n";
  9.   }
  10.   return 0;
  11. }
  12. /* test2.cpp */
  13. #include <iostream>
  14.  
  15. int main()
  16. {
  17.  for(unsigned int j=0;j<10000;j++){
  18.    unsigned long int sum=0;for(int i=0;i<10000;i++)if((i%3==0)||(i%5==0))sum+=i;
  19.    std::cout<<sum<<"\n";
  20.   }
  21.  return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment