题目链接
题目大意
判断任意b进制数y,判断下面定理是否正确:如果y%x=0,那么f(f(⋯f(y)⋯)%x=0(无限套娃)f(y)表示所有位数之和
题目思路
首先这种无限多的嵌套其实没必要被吓到,这个定义就是y%x=0那么f(y)%x=0,
首先观察样例样例为10进制,模数是3
任意一个10进制数可以表示为
x
=
1
0
0
c
0
+
1
0
1
c
1
+
1
0
2
c
2
.
.
.
.
.
.
x=10^0c_0+10^1c_1+10^2c_2......
x=100c0+101c1+102c2......
然后让x模3,推出
x
(
m
o
d
3
)
=
c
0
+
c
1
+
c
2
.
.
.
.
x(mod3 ) =c_0+c_1+c_2....
x(mod3)=c0+c1+c2....
显然f(x)%3=x%3
因为10%3=1,这算一个观察吧
严格证明如下
代码
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define fi first
#define se second
#define debug printf(" I am here\n");
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1e5+5,inf=0x3f3f3f3f,mod=1e9+7;
const double eps=1e-10;
ll b,x;
signed main(){
int _;scanf("%d",&_);
while(_--){
scanf("%lld%lld",&b,&x);
if(b%x==1){
printf("T\n");
}else{
printf("F\n");
}
}
return 0;
}