fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int a, b;
  5. scanf("%d%d", &a, &b);
  6.  
  7. int countA = (a - 1) / 4 - (a - 1) / 100 + (a - 1) / 400; // leap year from 1 to a
  8. int countB = b / 4 - b / 100 + b / 400; // leap year from 1 to b
  9.  
  10. int result = countB - countA; //count how many leap year between a and b
  11.  
  12. printf("%d", result);
  13. return 0;
  14. }
Success #stdin #stdout 0s 5320KB
stdin
2012 2016
stdout
2