fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. int monthday[] = {31, 28, 31, 30, 31, 30,
  6. 31, 31, 30, 31, 30, 31};
  7. int daymonthsum[12][31];
  8. int year, yearsum, month, day, pivot;
  9.  
  10. scanf("%d", &year);
  11.  
  12. if (isleap(year)) {
  13. monthday[2-1] += 1;
  14. }
  15.  
  16. yearsum = year%100 + year/100;
  17.  
  18. for (month = 1; month <= 12; ++month) {
  19. for (day = 1; day <= monthday[month-1]; ++day) {
  20. daymonthsum[month-1][day-1] = month + day + yearsum;
  21. }
  22. }
  23.  
  24. for (pivot = 12+31+yearsum; pivot >= 1+1+yearsum; --pivot) {
  25. for (month = 12; month >= 1; --month) {
  26. for (day = monthday[month-1]; day >= 1; --day) {
  27. if (daymonthsum[month-1][day-1] == pivot) {
  28. printf("%d%02d%02d = %d\n", year, month, day, pivot);
  29. }
  30. }
  31. }
  32. }
  33.  
  34. return 0;
  35. }
  36.  
  37.  
  38. int isleap(int year)
  39. {
  40. if (year % 400 == 0) {
  41. return 1;
  42. }
  43. if (year % 100 == 0) {
  44. return 0;
  45. }
  46. if (year % 4 == 0) {
  47. return 1;
  48. }
  49. return 0;
  50. }
Success #stdin #stdout 0s 2296KB
stdin
2013
stdout
20131231 = 76
20131230 = 75
20131229 = 74
20131130 = 74
20131031 = 74
20131228 = 73
20131129 = 73
20131030 = 73
20131227 = 72
20131128 = 72
20131029 = 72
20130930 = 72
20130831 = 72
20131226 = 71
20131127 = 71
20131028 = 71
20130929 = 71
20130830 = 71
20130731 = 71
20131225 = 70
20131126 = 70
20131027 = 70
20130928 = 70
20130829 = 70
20130730 = 70
20131224 = 69
20131125 = 69
20131026 = 69
20130927 = 69
20130828 = 69
20130729 = 69
20130630 = 69
20130531 = 69
20131223 = 68
20131124 = 68
20131025 = 68
20130926 = 68
20130827 = 68
20130728 = 68
20130629 = 68
20130530 = 68
20131222 = 67
20131123 = 67
20131024 = 67
20130925 = 67
20130826 = 67
20130727 = 67
20130628 = 67
20130529 = 67
20130430 = 67
20130331 = 67
20131221 = 66
20131122 = 66
20131023 = 66
20130924 = 66
20130825 = 66
20130726 = 66
20130627 = 66
20130528 = 66
20130429 = 66
20130330 = 66
20131220 = 65
20131121 = 65
20131022 = 65
20130923 = 65
20130824 = 65
20130725 = 65
20130626 = 65
20130527 = 65
20130428 = 65
20130329 = 65
20130131 = 65
20131219 = 64
20131120 = 64
20131021 = 64
20130922 = 64
20130823 = 64
20130724 = 64
20130625 = 64
20130526 = 64
20130427 = 64
20130328 = 64
20130130 = 64
20131218 = 63
20131119 = 63
20131020 = 63
20130921 = 63
20130822 = 63
20130723 = 63
20130624 = 63
20130525 = 63
20130426 = 63
20130327 = 63
20130228 = 63
20130129 = 63
20131217 = 62
20131118 = 62
20131019 = 62
20130920 = 62
20130821 = 62
20130722 = 62
20130623 = 62
20130524 = 62
20130425 = 62
20130326 = 62
20130227 = 62
20130128 = 62
20131216 = 61
20131117 = 61
20131018 = 61
20130919 = 61
20130820 = 61
20130721 = 61
20130622 = 61
20130523 = 61
20130424 = 61
20130325 = 61
20130226 = 61
20130127 = 61
20131215 = 60
20131116 = 60
20131017 = 60
20130918 = 60
20130819 = 60
20130720 = 60
20130621 = 60
20130522 = 60
20130423 = 60
20130324 = 60
20130225 = 60
20130126 = 60
20131214 = 59
20131115 = 59
20131016 = 59
20130917 = 59
20130818 = 59
20130719 = 59
20130620 = 59
20130521 = 59
20130422 = 59
20130323 = 59
20130224 = 59
20130125 = 59
20131213 = 58
20131114 = 58
20131015 = 58
20130916 = 58
20130817 = 58
20130718 = 58
20130619 = 58
20130520 = 58
20130421 = 58
20130322 = 58
20130223 = 58
20130124 = 58
20131212 = 57
20131113 = 57
20131014 = 57
20130915 = 57
20130816 = 57
20130717 = 57
20130618 = 57
20130519 = 57
20130420 = 57
20130321 = 57
20130222 = 57
20130123 = 57
20131211 = 56
20131112 = 56
20131013 = 56
20130914 = 56
20130815 = 56
20130716 = 56
20130617 = 56
20130518 = 56
20130419 = 56
20130320 = 56
20130221 = 56
20130122 = 56
20131210 = 55
20131111 = 55
20131012 = 55
20130913 = 55
20130814 = 55
20130715 = 55
20130616 = 55
20130517 = 55
20130418 = 55
20130319 = 55
20130220 = 55
20130121 = 55
20131209 = 54
20131110 = 54
20131011 = 54
20130912 = 54
20130813 = 54
20130714 = 54
20130615 = 54
20130516 = 54
20130417 = 54
20130318 = 54
20130219 = 54
20130120 = 54
20131208 = 53
20131109 = 53
20131010 = 53
20130911 = 53
20130812 = 53
20130713 = 53
20130614 = 53
20130515 = 53
20130416 = 53
20130317 = 53
20130218 = 53
20130119 = 53
20131207 = 52
20131108 = 52
20131009 = 52
20130910 = 52
20130811 = 52
20130712 = 52
20130613 = 52
20130514 = 52
20130415 = 52
20130316 = 52
20130217 = 52
20130118 = 52
20131206 = 51
20131107 = 51
20131008 = 51
20130909 = 51
20130810 = 51
20130711 = 51
20130612 = 51
20130513 = 51
20130414 = 51
20130315 = 51
20130216 = 51
20130117 = 51
20131205 = 50
20131106 = 50
20131007 = 50
20130908 = 50
20130809 = 50
20130710 = 50
20130611 = 50
20130512 = 50
20130413 = 50
20130314 = 50
20130215 = 50
20130116 = 50
20131204 = 49
20131105 = 49
20131006 = 49
20130907 = 49
20130808 = 49
20130709 = 49
20130610 = 49
20130511 = 49
20130412 = 49
20130313 = 49
20130214 = 49
20130115 = 49
20131203 = 48
20131104 = 48
20131005 = 48
20130906 = 48
20130807 = 48
20130708 = 48
20130609 = 48
20130510 = 48
20130411 = 48
20130312 = 48
20130213 = 48
20130114 = 48
20131202 = 47
20131103 = 47
20131004 = 47
20130905 = 47
20130806 = 47
20130707 = 47
20130608 = 47
20130509 = 47
20130410 = 47
20130311 = 47
20130212 = 47
20130113 = 47
20131201 = 46
20131102 = 46
20131003 = 46
20130904 = 46
20130805 = 46
20130706 = 46
20130607 = 46
20130508 = 46
20130409 = 46
20130310 = 46
20130211 = 46
20130112 = 46
20131101 = 45
20131002 = 45
20130903 = 45
20130804 = 45
20130705 = 45
20130606 = 45
20130507 = 45
20130408 = 45
20130309 = 45
20130210 = 45
20130111 = 45
20131001 = 44
20130902 = 44
20130803 = 44
20130704 = 44
20130605 = 44
20130506 = 44
20130407 = 44
20130308 = 44
20130209 = 44
20130110 = 44
20130901 = 43
20130802 = 43
20130703 = 43
20130604 = 43
20130505 = 43
20130406 = 43
20130307 = 43
20130208 = 43
20130109 = 43
20130801 = 42
20130702 = 42
20130603 = 42
20130504 = 42
20130405 = 42
20130306 = 42
20130207 = 42
20130108 = 42
20130701 = 41
20130602 = 41
20130503 = 41
20130404 = 41
20130305 = 41
20130206 = 41
20130107 = 41
20130601 = 40
20130502 = 40
20130403 = 40
20130304 = 40
20130205 = 40
20130106 = 40
20130501 = 39
20130402 = 39
20130303 = 39
20130204 = 39
20130105 = 39
20130401 = 38
20130302 = 38
20130203 = 38
20130104 = 38
20130301 = 37
20130202 = 37
20130103 = 37
20130201 = 36
20130102 = 36
20130101 = 35