提交时间:2021-05-21 20:52:26

运行 ID: 19719

#include<bits/stdc++.h> using namespace std; int h[10010]={0,1},h2[10010]={0,2},h3[10010]={0,3},h5[10010]={0,5},h7[10010]={0,7}; int t2=1,t3=1,t5=1,t7=1,n,mh; int main(){ cin>>n; for(int i=2;i<=n+1;i++){ mh=min(h2[t2],min(h3[t3],min(h5[t5],h7[t7]))); h[i]=mh,h2[i]=2*mh,h3[i]=3*mh,h5[i]=5*mh,h7[i]=7*mh; if(h2[t2]==mh) t2++; if(h3[t3]==mh) t3++; if(h5[t5]==mh) t5++; if(h7[t7]==mh) t7++; } cout<<h[n+1]; }