fork(3) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. long long int wypunktuj(int r);
  6.  
  7. int main()
  8. {
  9. int ile;
  10. int a, b;
  11.  
  12. cin >> ile;
  13.  
  14. if(ile <= 400000)
  15. {
  16. for(int i = 0; i < ile; i++)
  17. {
  18. cin >> a >> b;
  19.  
  20. cout << wypunktuj(b) - wypunktuj(a-1) << endl;
  21. }
  22. }
  23.  
  24. return 0;
  25. }
  26.  
  27. long long int wypunktuj(int r)
  28. {
  29. int a,b,c,d,e;
  30. a = r/3;
  31. b = r/5;
  32. c = r/10;
  33. d = b/3;
  34. e = c/3;
  35. a = a-d;
  36. d = d-e;
  37. c = c-e;
  38. b = b-c-d-e;
  39. return a*3 + b*5 + d*15 + c*50 + e*150;
  40. }
  41.  
Success #stdin #stdout 0s 2732KB
stdin
3
1 8
28 37
3 64
stdout
11
161
601