 F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist

C/C++/Java Exams
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
DIY | Web-DIY beta Author ID Password
Register new ID

# Divisibility

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 662    Accepted Submission(s): 452

Problem Description
You are given two $10$-based integers $b$ and $x$, and you are required to determine the following proposition is true or false:

For arbitrary $b$-based positive integer $y = \overline{c_1 c_2 \cdots c_n}$ ($c_i$ is the $i$-th dight from left of $y$), define $\displaystyle f(y) = \sum_{i=1}^n c_i$, if $\underbrace{f( f( \cdots f(y) \cdots ))}_{\infty}$ can be divided by $x$, then $y$ can be divided by $x$, otherwise $y$ can't be divided by $x$.

Input
The first line contains a $10$-based integer $t\ (1 \leq t \leq 10^5)$ ― the number of test cases.

For each test case, there is a single line containing two $10$-based integers $b$ and $x \ (2 \leq b,x \leq 10^{18})$.

Output
For each test case, if the proposition is true, print "T", otherwise print "F" (without quotes).

Sample Input
1
10 3


Sample Output
T


Source

Statistic | Submit | Discuss | Note
 Home | Top Hangzhou Dianzi University Online Judge 3.0 Copyright © 2005-2023 HDU ACM Team. All Rights Reserved. Designer & Developer : Wang Rongtao LinLe GaoJie GanLu Total 0.000000(s) query 1, Server time : 2023-06-01 01:25:12, Gzip enabled Administration