fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int getID(const int fpass, const int Fstop)
  5. {
  6. const int d = -1;
  7. const int a1 = 9;
  8. const int n = (fpass / 60);
  9. const int an = (a1 - n);
  10. const int sum = (n * (2 * a1 + (n - 1) * d)) / 2;
  11. return sum + (Fstop - fpass) / 60 - 1;
  12. }
  13.  
  14. int main(int argc, char* argv[])
  15. {
  16. int Fpass, Fstop;
  17. const int begin = 0;
  18. const int end = 540;
  19. const int step = 60;
  20. for (Fpass = begin; Fpass <= end; Fpass += step) {
  21. for (Fstop = Fpass + step; Fstop <= end; Fstop += step) {
  22. printf("%d %d %d\n", Fpass, Fstop, getID(Fpass, Fstop));
  23. }
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 2008KB
stdin
Standard input is empty
stdout
0 60 0
0 120 1
0 180 2
0 240 3
0 300 4
0 360 5
0 420 6
0 480 7
0 540 8
60 120 9
60 180 10
60 240 11
60 300 12
60 360 13
60 420 14
60 480 15
60 540 16
120 180 17
120 240 18
120 300 19
120 360 20
120 420 21
120 480 22
120 540 23
180 240 24
180 300 25
180 360 26
180 420 27
180 480 28
180 540 29
240 300 30
240 360 31
240 420 32
240 480 33
240 540 34
300 360 35
300 420 36
300 480 37
300 540 38
360 420 39
360 480 40
360 540 41
420 480 42
420 540 43
480 540 44