CF1674A Number Transformation 题解
题意简述
给定正整数 $ x, y $。求 $ x \times b^a = y $ 中 $ a, b $ 的一组合法正整数解;若没有合法正整数解,则输出 $ 0\ 0 $。
Sol:
原式可化为 $ b^a = \frac{y}{x} $。
令 $ a = 1 $,则 $ b = \frac{y}{x} $,即当且仅当 $ x \mid y $ 时,原式有合法正整数解。
特判一下,输出 $ 1 $ 与 $ \frac{y}{x} $ 即可。
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int main(){
ll T;
cin >> T;
while(T--){
ll x,y;
cin >> x >> y;
if(y % x == 0)cout << 1 << " " << y/x << endl;
else cout << 0 << " " << 0 << endl;
}
return 0;
}

浙公网安备 33010602011771号