直接倒序输出即可
#include <cstdio>
#include <iostream>
#include <string.h>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stack>
#include <iomanip>
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
const int maxn=100005,inf=0x3f3f3f3f;
const ll llinf=0x3f3f3f3f3f3f3f3f;
const ld pi=acos(-1.0L);
char s[maxn];
int main() {
scanf("%s",s);
int i,len=strlen(s);
for (i=0;i<len;i++) {
printf("%c",s[i]);
}
for (i=len-1;i>=0;i--) {
printf("%c",s[i]);
}
return 0;
}
B. Recursive Queries
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Let us define two functions f and g on positive integer numbers.
![](https://i-blog.csdnimg.cn/blog_migrate/104281f418cce90b4c7b41182ccb7309.png)
You need to process Q queries. In each query, you will be given three integers l, r and k. You need to print the number of integers x between l and r inclusive, such that g(x) = k.
Input
The first line of the input contains an integer Q (1 ≤ Q ≤ 2 × 105) representing the number of queries.
Q lines follow, each of which contains 3 integers l, r and k (1 ≤ l ≤ r ≤ 106, 1 ≤ k ≤ 9).
Output
For each query, print a single line containing the answer for that query.
Examples