fork download
  1. #include <iostream>
  2. #include <math.h>
  3. #include <string>
  4. #include <map>
  5. #include <string.h>
  6. #include <vector>
  7. #include <time.h>
  8. #include <algorithm>
  9.  
  10. using namespace std;
  11. int toint(char c){
  12. return c-'0';
  13. }
  14. bool validtime(string s){
  15. if (toint(s[0]) !=3 && toint(s[1]) !=3 && toint(s[3]) !=3 && toint(s[4]) !=3 &&
  16. toint(s[0]) !=4 && toint(s[1]) !=4 && toint(s[3]) !=4 && toint(s[4]) !=4 &&
  17. toint(s[0]) !=7 && toint(s[1]) !=7 && toint(s[3]) !=7 && toint(s[4]) !=7){
  18. if (toint(s[4]) > 2) return false;
  19. if (toint(s[4]) == 2 && toint(s[3]) > 3) return false;
  20. return true;
  21. }
  22. else return false;
  23.  
  24. }
  25. int formattoint(string s){
  26. return (toint(s[0])*10+toint(s[1]))*60+(toint(s[3])*10+toint(s[4]));
  27. }
  28. string toformat(int time){
  29. string s;
  30. s+=to_string(time/600);
  31. s+=to_string((time/60)%10);
  32. s+=":";
  33. s+=to_string((time%60)/10);
  34. s+=to_string((time%60)%10);
  35. return s;
  36. }
  37.  
  38.  
  39. int main() {
  40. string s1,s2;
  41. char ch;
  42. int t;
  43. cin >> t;
  44.  
  45. for (int i = 0; i < t; i++) {
  46. int count=0;
  47. //getline(cin, s);
  48. cin>>s1>>ch>>s2;
  49. if (formattoint(s1)<=formattoint(s2)){
  50. for (int time = formattoint(s1);time<=formattoint(s2);time++) {
  51. if (validtime(toformat(time))){cout<<toformat(time)<<"\n"; count++;}
  52. }
  53. }
  54. else{
  55. for (int time = formattoint(s1);time<1440;time++) {
  56. if (validtime(toformat(time))) count++;
  57. }
  58. for (int time = 0;time<=formattoint(s2);time++) {
  59. if (validtime(toformat(time))) count++;
  60. }
  61. }
  62. cout<<count<<endl;
  63. }
  64. return 0;
  65. }
Success #stdin #stdout 0s 15240KB
stdin
1
21:00 - 00:13
stdout
28