How to AK NOI Online2022-junior
__vector__ · · 个人记录
前言:
因为 T2忘了写一种情况,导致
T1-kingdom
太水了,不写。
T2-math
题目解法:
设
因为
现在求出了
\color{green}\text{AC 代码:}
#include <bits/stdc++.h>
using namespace std;
namespace Main
{
typedef long long ll;
int t;
ll x,z;
inline ll read()
{
ll x=0,f=1;
char ch=getchar();
while(!isdigit(ch))
{
if(ch=='-')f=-1;
ch=getchar();
}
while(isdigit(ch))
{
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
inline void write(ll x)
{
if(x<0)
{
x=-x;
putchar('-');
}
if(x>=10)write(x/10);
putchar(x%10^48);
}
inline ll gcd(ll a,ll b)
{
return !b?a:gcd(b,a%b);
}
void main()
{
scanf("%d",&t);
ll y;
while(t--)
{
x=read();
z=read();
if(z%x!=0)
{
write(-1);
putchar('\n');
continue;
}
y=(z/x)/sqrt(gcd(x*x,z/x));
if(x*y*gcd(x,y)!=z)
{
write(-1);
putchar('\n');
continue;
}
write(y);
putchar('\n');
}
#ifndef ONLINE_JUDGE
system("pause");
#endif
}
}
int main()
{
Main::main();
return 0;
}
T3-string
咕咕咕