# s-palindrome

## 题面翻译

是输出“TAK”，不是输出“NIE”。
@[chen_zhe](/space/show?uid=8457) @[yjjr](/space/show?uid=5088)


## 题目描述

Let’s call a string “s-palindrome” if it is symmetric about the middle of the string.

For example, the string “oHo” is “s-palindrome”, but the string “aa” is not.

The string “aa” is not “s-palindrome”, because the second half of it is not a mirror reflection of the first half. English alphabetYou are given a string s s .

Check if the string is “s-palindrome”.

## 输入格式

The only line contains the string s s ( 1 < = ∣ s ∣ < = 1000 1<=|s|<=1000 ) which consists of only English letters.

## 输出格式

Print “TAK” if the string s s is “s-palindrome” and “NIE” otherwise.

## 样例 #1

### 样例输入 #1

oXoxoXo


### 样例输出 #1

TAK


## 样例 #2

### 样例输入 #2

bod


### 样例输出 #2

TAK


## 样例 #3

### 样例输入 #3

ER


### 样例输出 #3

NIE

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
typedef long long ll;
char s;
char f;
int l;
int main(){
f['A']='A';f['H']='H';f['I']='I';f['M']='M';f['O']='O';f['T']='T';
f['U']='U';f['V']='V';f['W']='W';f['X']='X';f['Y']='Y';f['b']='d';
f['d']='b';f['o']='o';f['p']='q';f['q']='p';f['v']='v';f['w']='w';
f['x']='x';
scanf("%s",s);
l=strlen(s);
for(int i=0,j=l-1;i<=j;++i,--j){
if(f[s[i]]!=s[j]){
puts("NIE");return 0;
}
}
puts("TAK");
return 0;
}


# Memory and De-Evolution

## 题面翻译

Memory对物体，尤其是三角形的变化感兴趣。 他有一个边长为x的等边三角形，他希望通过一些操作获得一个边长为y的等边三角形。

Memory要获得边长y的等边三角形，所需的最小修改次数是多少？

## 题目描述

Memory is now interested in the de-evolution of objects, specifically triangles.

He starts with an equilateral triangle of side length x x , and he wishes to perform operations to obtain an equilateral triangle of side length y y .

In a single second, he can modify the length of a single side of the current triangle such that it remains a non-degenerate triangle (triangle of positive area).

At any moment of time, the length of each side should be integer.

What is the minimum number of seconds required for Memory to obtain the equilateral triangle of side length y y ?

## 输入格式

The first and only line contains two integers x x and y y ( KaTeX parse error: Expected 'EOF', got '&' at position 5: 3<=y&̲lt;x<=100000 ) — the starting and ending equilateral triangle side lengths respectively.

## 输出格式

Print a single integer — the minimum number of seconds required for Memory to obtain the equilateral triangle of side length y y if he starts with the equilateral triangle of side length x x .

## 样例 #1

### 样例输入 #1

6 3


### 样例输出 #1

4


## 样例 #2

### 样例输入 #2

8 5


### 样例输出 #2

3


## 样例 #3

### 样例输入 #3

22 4


### 样例输出 #3

6


## 提示

In the first sample test, Memory starts with an equilateral triangle of side length 6 6 and wants one of side length 3 3 .

Denote a triangle with sides a a , b b , and c c as ( a , b , c ) (a,b,c) .

Then, Memory can do .

In the second sample test, Memory can do .

In the third sample test, Memory can do:  .

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
typedef long long ll;
int x,y,a,k=0;
int main(){
cin>>x>>y;
a=a=a=y;
while(a<x||a<x||a<x){
k++;
sort(a+1,a+4);
a=a+a-1;
}
cout<<k<<endl;
return 0;
}


# The Same Calendar

## 题目描述

The girl Taylor has a beautiful calendar for the year y y .

In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.

The calendar is so beautiful that she wants to know what is the next year after y y when the calendar will be exactly the same.

Help Taylor to find that year.

Note that leap years has 366 366 days. The year is leap if it is divisible by 400 400 or it is divisible by 4 4 , but not by 100 100 (https://en.wikipedia.org/wiki/Leap_year).

## 输入格式

The only line contains integer y y ( KaTeX parse error: Expected 'EOF', got '&' at position 8: 1000<=y&̲lt;100'000 ) — the year of the calendar.

## 输出格式

Print the only integer y ′ y' — the next year after y y when the calendar will be the same.

Note that you should find the first year after y y with the same calendar.

## 样例 #1

### 样例输入 #1

2016


### 样例输出 #1

2044


## 样例 #2

### 样例输入 #2

2000


### 样例输出 #2

2028


## 样例 #3

### 样例输入 #3

50501


### 样例输出 #3

50507


## 提示

Today is Monday, the 13 13 th of June, 2016 2016 .

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
typedef long long ll;
int n,m,k;
bool check(int x){
if((x%4==0&&x%100!=0)||x%400==0)return 1;
return 0;
}
int main(){
cin>>n;
m=n;
do{
++m;
k=(k+365+check(m))%7;
}while(!(check(n)==check(m)&&k==0));
cout<<m<<endl;
return 0;
}


# Tennis Championship

## 题面翻译

n < = 1 0 18 n <= 10^{18}

## 题目描述

Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn’t want to miss this event.

There will be n n players participating, and the tournament will follow knockout rules from the very first game.

That means, that if someone loses a game he leaves the tournament immediately.

Organizers are still arranging tournament grid (i.e. the order games will happen and who is going to play with whom) but they have already fixed one rule: two players can play against each other only if the number of games one of them has already played differs by no more than one from the number of games the other one has already played.

Of course, both players had to win all their games in order to continue participating in the tournament.

Tournament hasn’t started yet so the audience is a bit bored.

Ostap decided to find out what is the maximum number of games the winner of the tournament can take part in (assuming the rule above is used).

However, it is unlikely he can deal with this problem without your help.

## 输入格式

The only line of the input contains a single integer n n ( 2 < = n < = 1 0 18 2<=n<=10^{18} ) — the number of players to participate in the tournament.

## 输出格式

Print the maximum number of games in which the winner of the tournament can take part.

## 样例 #1

### 样例输入 #1

2


### 样例输出 #1

1


## 样例 #2

### 样例输入 #2

3


### 样例输出 #2

2


## 样例 #3

### 样例输入 #3

4


### 样例输出 #3

2


## 样例 #4

### 样例输入 #4

10


### 样例输出 #4

4


## 提示

In all samples we consider that player number 1 1 is the winner.

In the first sample, there would be only one game so the answer is 1 1 .

In the second sample, player 1 1 can consequently beat players 2 2 and 3 3 .

In the third sample, player 1 1 can’t play with each other player as after he plays with players 2 2 and 3 3 he can’t play against player 4 4 , as he has 0 0 games played, while player 1 1 already played 2 2 .

Thus, the answer is 2 2 and to achieve we make pairs ( 1 , 2 ) (1,2) and ( 3 , 4 ) (3,4) and then clash the winners.

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
typedef long long ll;
ll n,s1=1,s2=2,s3=3,k=1;
int main(){
cin>>n;
while(s3<=n){
s1=s2;
s2=s3;
s3=s1+s2;
k++;
}
cout<<k<<endl;
return 0;
}


# Buses Between Cities

## 题面翻译

### 题目大意

A A市和B B市之间有公交车行驶，第一班是早上5 : 00 5:00，最后一班不迟于晚上11 : 59 11:59开出。

A A市出发的公共汽车每隔a a分钟发车，到B B市需t a t_a分钟，从B B市出发的公共汽车每隔b b分钟发一辆车，到A A市需t b t_b分钟。

### 输入格式

ps:a , t a , b , t b a,t_a,b,t_b单位均为分钟。

ps:S i m o n SimonA A市出发时一定有一辆公交车从A A市开出。

### 输出格式

( t r a n s l a t e d (translated b y by D r e a m i n g B o y W o n d e r s ) DreamingBoyWonders)

## 题目描述

Buses run between the cities A A and B B , the first one is at 05:00 AM and the last one departs not later than at 11:59 PM.

A bus from the city A A departs every a a minutes and arrives to the city B B in a t a t_{a} minutes, and a bus from the city B B departs every b b minutes and arrives to the city A A in a t b t_{b} minutes.

The driver Simion wants to make his job diverse, so he counts the buses going towards him.

Simion doesn’t count the buses he meet at the start and finish.

You know the time when Simion departed from the city A A to the city B B .

Calculate the number of buses Simion will meet to be sure in his counting.

## 输入格式

The first line contains two integers a , t a a,t_{a} ( 1 < = a , t a < = 120 1<=a,t_{a}<=120 ) — the frequency of the buses from the city A A to the city B B and the travel time.

Both values are given in minutes.

The second line contains two integers b , t b b,t_{b} ( 1 < = b , t b < = 120 1<=b,t_{b}<=120 ) — the frequency of the buses from the city B B to the city A A and the travel time.

Both values are given in minutes.

The last line contains the departure time of Simion from the city A A in the format hh:mm.

It is guaranteed that there are a bus from the city A A at that time.

Note that the hours and the minutes are given with exactly two digits.

## 输出格式

Print the only integer z z — the number of buses Simion will meet on the way.

Note that you should not count the encounters in cities A A and B B .

## 样例 #1

### 样例输入 #1

10 30
10 35
05:20


### 样例输出 #1

5


## 样例 #2

### 样例输入 #2

60 120
24 100
13:00


### 样例输出 #2

9


## 提示

In the first example Simion departs form the city A A at 05:20 AM and arrives to the city B B at 05:50 AM. He will meet the first 5 5 buses from the city B B that departed in the period [05:00 AM - 05:40 AM].

Also Simion will meet a bus in the city B B at 05:50 AM, but he will not count it.

Also note that the first encounter will be between 05:26 AM and 05:27 AM (if we suggest that the buses are go with the sustained speed).

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
typedef long long ll;
int a,b,ta,tb,h,m;
int main(){
scanf("%d%d%d%d%d:%d",&a,&ta,&b,&tb,&h,&m);
m+=h*60;
h=0;
a=300;
while(a<m+ta&&a<1440){
if(a+tb>m) h++;
a+=b;
}
cout<<h<<endl;
return 0;
}