120564G
https://ac.nowcoder.com/acm/contest/120564/G
怎么想到的?
虽然看起来很多,但在
的意义下,很多数是本质相同的。例如,
就和
以及在它们中间各种插入
的数(如
等)本质相同。除此之外,含有
的一堆数,固定几个数的全排列,等等等等,都是一堆本质相同的数在那里颠来倒去。
由此可以猜测:本质不同的数非常有限。再看看那些本质相同的数,都是由它们每个数位的数字质因数分解后的乘积相同导致的。所以得到一个推论:只要两个数的每个数位上的数质因数分解后的乘积不同,它们就本质不同。
于是我们只要枚举的个数就可以找出所有本质不同的数了。当然由于
碰到偶数就会归零,可以不枚举
。同时注意:
可以合成
,
可以合成
,所以
有
种情况,
有
种情况,
只有
种情况。循环枚举找到
最多的那个数即可。
#include<bits/stdc++.h>
using namespace std;
const __int128 inf=1e18;
__int128 read(){
char ch=getchar();__int128 x=0,f=1;
while(ch<'0'||ch>'9'){
if(ch=='-') f=-1;
ch=getchar();
}
while(ch<='9'&&ch>='0'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
__int128 g(__int128 x){
__int128 cnt=0;
while(x>9){
__int128 y=x,res=1;
while(y){
res*=y%10;
y/=10;
}
x=res;
// cout<<x<<endl;
cnt++;
}
return cnt;
}
__int128 ksm(__int128 a,__int128 b){
__int128 res=1;
while(b){
if(b&1){
res=res*a;
}
a=a*a;
b>>=1;
}
return res;
}
int main(){
int ma=0,_2=0,_3=0,_7=0;
for(__int128 i=0;i<=54;i++){
__int128 x=ksm(2,i);
for(__int128 j=0;j<=36;j++){
__int128 y=x*ksm(3,j);
for(__int128 k=0;k<=18;k++){
__int128 z=y*ksm(7,k);
if(z>inf) break;
int h=g(z);
if(h>ma){//得到ma=10后就改成h==10 可以得到两组解
ma=h;
_2=i;
_3=j;
_7=k;
}
}
if(y>inf) break;
}
if(x>inf) break;
}
cout<<_2<<' '<<_3<<' '<<_7<<endl;
return 0;
}
找出来两组解:个。合成整数
(注意
)。输出即可。
答案:
#include<bits/stdc++.h>
using namespace std;
int read(){
char ch=getchar();int x=0,f=1;
while(ch<'0'||ch>'9'){
if(ch=='-') f=-1;
ch=getchar();
}
while(ch<='9'&&ch>='0'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
int main(){
puts("66667777799999999 666688888777777") ;
return 0;
}

查看5道真题和解析
OPPO公司福利 1225人发布