Advertisement
a53

momente

a53
Jul 4th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin ("momente.in");
  6. ofstream fout ("momente.out");
  7.  
  8. int N, l1, z1, h1, m1, s1, l2, z2, h2, m2, s2, a[90001];
  9. const int Luni[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  10.  
  11. int Zile_Complete () {
  12. if (l1 == l2)
  13. return z2 - z1 - 1;
  14. int z = Luni[l1] - z1 + z2 - 1;
  15. for (int i = l1 + 1; i < l2; i ++)
  16. z += Luni[i];
  17. return z;
  18. }
  19.  
  20. int Invers (int x) {
  21. int inv = 0;
  22. while (x)
  23. inv = inv * 10 + x % 10, x /= 10;
  24. return inv;
  25. }
  26.  
  27. void Palindroame () {
  28. int ora = 0;
  29. a[1] = 1;
  30. for (int i = 2; i <= 3600 * 24 - 1; i ++) {
  31. ora ++;
  32. a[i] = a[i - 1];
  33. if (ora == Invers(ora))
  34. a[i] ++;
  35. if (ora % 100 == 60)
  36. ora += 40;
  37. if (ora % 10000 / 100 == 60)
  38. ora += 4000;
  39. }
  40. }
  41.  
  42. inline int Secunde (int h, int m, int s) {
  43. return h * 3600 + m * 60 + s;
  44. }
  45.  
  46. int main () {
  47. fin >> N;
  48. Palindroame();
  49. a[86400] = 699;
  50. for (int i = 0; i < N; i ++) {
  51. fin >> l1 >> z1 >> h1 >> m1 >> s1 >> l2 >> z2 >> h2 >> m2 >> s2;
  52. int ans = 0;
  53. ans = Zile_Complete() * 699;
  54. ans += 699 - a[Secunde (h1, m1, s1)];
  55. ans += a[Secunde (h2, m2, s2) + 1];
  56. fout << ans << '\n';
  57. }
  58. fin.close();
  59. fout.close();
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement