fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. template<class T> inline int isLeapYear(const T y){
  5. if(y%4){
  6. return 0;
  7. }
  8. if(y%100){
  9. return 1;
  10. }
  11. if(y%400){
  12. return 0;
  13. }
  14. return 1;
  15. }
  16. inline long long dayIndex(long long y, int m, int d){
  17. static int sm[13] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
  18. long long p;
  19. long long res = 1;
  20. p = (y-1) / 400;
  21. res += p * 146097;
  22. y -= p * 400;
  23. res += (y-1) * 365 + (y-1) / 4 - (y-1) / 100 + sm[m] + d-1;
  24. if(m >= 3 && isLeapYear(y)){
  25. res++;
  26. }
  27. return res;
  28. }
  29. #define main dummy_main
  30. int main(){
  31. return 0;
  32. }
  33. #undef main
  34. class Solution{
  35. public:
  36. int daysBetweenDates(string date1, string date2){
  37. int y1;
  38. int y2;
  39. int m1;
  40. int m2;
  41. int d1;
  42. int d2;
  43. sscanf(date1.c_str(), "%d-%d-%d", &y1, &m1, &d1);
  44. sscanf(date2.c_str(), "%d-%d-%d", &y2, &m2, &d2);
  45. return abs( dayIndex(y1,m1,d1) - dayIndex(y2,m2,d2) );
  46. }
  47. }
  48. ;
  49. // cLay varsion 20200227-1
  50.  
  51. // --- original code ---
  52. // #define main dummy_main
  53. // {}
  54. // #undef main
  55. //
  56. // class Solution {
  57. // public:
  58. // int daysBetweenDates(string date1, string date2) {
  59. // int y1, y2, m1, m2, d1, d2;
  60. // sscanf(date1.c_str(), "%d-%d-%d", &y1, &m1, &d1);
  61. // sscanf(date2.c_str(), "%d-%d-%d", &y2, &m2, &d2);
  62. // return abs( dayIndex(y1,m1,d1) - dayIndex(y2,m2,d2) );
  63. // }
  64. // };
  65.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty