[Codeforces] Friday the 13th, Programmers Day C. Counting Fridays

Friday the 13th, Programmers Day C. Counting Fridays

  • Time :
  • Space :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

With Gnat.IO; use Gnat.IO;

procedure Main is
caso, sz : Integer;
ln : String(1..10);
c : Character;
y, m, d, di, cnt: Integer;

begin
get(caso);
cnt:=0;
for i in 1 .. caso loop
get(y); get(c); get(m); get(c); get(d);
di:= 1461 * (y + 4800 + (m - 14) / 12) / 4 +
367 * (m - 2 - (m - 14) / 12 * 12) / 12 -
3 * ((y + 4900 + (m - 14) / 12) / 100) / 4 +
d - 32075;

if d = 13 and (di mod 7) = 4 then
cnt := cnt+1;
end if;

end loop;

put(cnt);

end Main;
Author: Song Hayoung
Link: https://songhayoung.github.io/2023/12/06/PS/Codeforces/friday-the-13th-programmers-day-c/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.