CF1792E 解题报告(杂题选做)
前言
求证明复杂度。
摘自 杂题选做。
思路分析
肯定要先求
直接求会爆,所以我们分开求出所有因子然后合并。
有关这个因子的数量我们可以查表:
其中
发现
然后考虑怎么求最小出现行数。
假设我们已经求完了所有因子扔在了
那么我们不难发现,
这点证明也很容易,
那么我们现在要求的就是:
前面是要求的,后面的是判断条件。
这样我们不难想到,先把最前面一段
这样就搞出来了一种很优秀的暴力,直接提交发现可过。
代码
#include<bits/stdc++.h>
#define ls (p<<1)
#define rs (ls|1)
#define mid ((l+r)>>1)
#define int long long
using namespace std;
const int N=2e6+10,V=1e6,M=35,INF=1e9+10,mod=1e9+7;
int n,m1,m2,tot,cnt,cur,a[N],b[N],c[N];
namespace Fast_IO
{
static char buf[1000000],*paa=buf,*pd=buf,out[10000000];int length=0;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline int read()
{
int x(0),t(1);char fc(getchar());
while(!isdigit(fc)){if(fc=='-') t=-1;fc=getchar();}
while(isdigit(fc)) x=(x<<1)+(x<<3)+(fc^48),fc=getchar();
return x*t;
}
inline void flush(){fwrite(out,1,length,stdout);length=0;}
inline void put(char c){if(length==9999999) flush();out[length++]=c;}
inline void put(string s){for(char c:s) put(c);}
inline void print(int x)
{
if(x<0) put('-'),x=-x;
if(x>9) print(x/10);
put(x%10+'0');
}
inline bool chk(char c) { return !(c>='a'&&c<='z'||c>='A'&&c<='Z'||c>='0'&&c<='9'); }
inline bool ck(char c) { return c!='\n'&&c!='\r'&&c!=-1&&c!=' '; }
inline void rd(char s[],int&n)
{
s[++n]=getchar();
while(chk(s[n])) s[n]=getchar();
while(ck(s[n])) s[++n]=getchar();
n--;
}
}
using namespace Fast_IO;
inline void solve()
{
n=read(),m1=read(),m2=read();tot=cnt=cur=0;
for(int i=1;i*i<=m1;i++) if(m1%i==0) a[++tot]=i,a[++tot]=m1/i;
for(int i=1;i*i<=m2;i++) if(m2%i==0) b[++cnt]=i,b[++cnt]=m2/i;
for(int i=1;i<=tot;i++) for(int j=1;j<=cnt;j++) c[++cur]=a[i]*b[j];
sort(c+1,c+1+cur);cur=unique(c+1,c+1+cur)-c-1;tot=cnt=0;
for(int i=1;i<=cur;i++)
{
int l=1,r=i,res=1;
while(l<=r)
if((c[i]+c[mid]-1)/c[mid]<=n) res=mid,r=mid-1;
else l=mid+1;
for(int j=res;j<=i&&c[j]<=n;j++)
if(c[i]%c[j]==0){tot++;cnt^=c[j];break;}
}print(tot),put(' '),print(cnt);put('\n');
}
signed main()
{
int T=1;
T=read();
while(T--) solve();
genshin:;flush();return 0;
}