#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
bool isPal(int h, int m)
{
vector<int> vec, tmp, vec2 ;
if(h == 0)
{
if(m < 10)
return true;
else
{
while(m != 0)
{
vec.push_back(m%10);
m/=10;
}
tmp = vec;
reverse(vec.begin(), vec.end());
if(vec == tmp)
return true;
else
return false;
}
}
else
{
while(h != 0)
{
vec.push_back(h % 10);
h/=10;
}
reverse(vec.begin(), vec.end());
if(m<10)
vec.push_back(0);
while(m != 0)
{
vec2.push_back(m % 10);
m/=10;
}
reverse(vec2.begin(), vec2.end());
vec.insert(vec.end(), vec2.begin(), vec2.end());
tmp = vec;
reverse(vec.begin(), vec.end());
if(vec == tmp)
return true;
else
return false;
}
}
int main()
{
int casos, hh, mm;
bool flag = 0;
scanf("%d", &casos);
while(casos--)
{
scanf("%d:%d", &hh, &mm);
flag = false;
while(flag != 1)
{
mm++;
if(mm == 60)
{
mm = 0;
hh++;
if(hh == 24)
hh = 0;
}
if(isPal(hh,mm))
{
flag = true;
if(hh < 10)
printf("0");
printf("%d:", hh);
if(mm<10)
printf("0");
printf("%d\n", mm);
}
}
}
return 0;
}
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
bool isPal(int h, int m)
{
vector<int> vec, tmp, vec2 ;
if(h == 0)
{
if(m < 10)
return true;
else
{
while(m != 0)
{
vec.push_back(m%10);
m/=10;
}
tmp = vec;
reverse(vec.begin(), vec.end());
if(vec == tmp)
return true;
else
return false;
}
}
else
{
while(h != 0)
{
vec.push_back(h % 10);
h/=10;
}
reverse(vec.begin(), vec.end());
if(m<10)
vec.push_back(0);
while(m != 0)
{
vec2.push_back(m % 10);
m/=10;
}
reverse(vec2.begin(), vec2.end());
vec.insert(vec.end(), vec2.begin(), vec2.end());
tmp = vec;
reverse(vec.begin(), vec.end());
if(vec == tmp)
return true;
else
return false;
}
}
int main()
{
int casos, hh, mm;
bool flag = 0;
scanf("%d", &casos);
while(casos--)
{
scanf("%d:%d", &hh, &mm);
flag = false;
while(flag != 1)
{
mm++;
if(mm == 60)
{
mm = 0;
hh++;
if(hh == 24)
hh = 0;
}
if(isPal(hh,mm))
{
flag = true;
if(hh < 10)
printf("0");
printf("%d:", hh);
if(mm<10)
printf("0");
printf("%d\n", mm);
}
}
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন