总结:
T1需要拿全分;
T2弃疗;
T3也应该拿全分;
T4应该做出70%的数据;
<-__<-
T1:
http://blog.csdn.net/qq_36312502/article/details/78249623
T2:
https://www.luogu.org/problem/show?pid=1039
T3:
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
char c,s[5000002];
int n;
int dp[11];
char biao[]={'\0','h','e','l','l','o','w','o','r','l','d'};
void read()
{
while(scanf("%c",&c)!=EOF)
{
if(c=='\n' || c=='\0') continue;
else if(c=='H') c='h';
else if(c=='E') c='e';
else if(c=='L') c='l';
else if(c=='O') c='o';
else if(c=='W') c='w';
else if(c=='R') c='r';
else if(c=='D') c='d';
s[++n]=c;
}
return;
}
void solve()
{
read(),dp[0]=1;
for(int i=1;i<=n;i++)
for(int j=10;j>=1;j--)
if(s[i]==biao[j])
dp[j]=(dp[j-1]+dp[j])%mod;
cout<<dp[10]<<endl;
}
int main()
{
freopen("helloworld.in","r",stdin);
freopen("helloworld.out","w",stdout);
solve();
fclose(stdin);
fclose(stdout);
return 0;
}
T4:
https://www.luogu.org/problem/show?pid=3927
ans的初始值一定要设大;
思路:
k=10时,0的个数就是n!中min(2的数量,5的数量);
对n!质因数分解;
n!的质因数分解详见:http://blog.csdn.net/qq_36312502/article/details/78044719
一样的思路;
对k进行质因数分解,
假设k的某一质因数为s,在k中有num个,在n中有cnt个;
则ans=min(ans,cnt/num);
由于n,k很大,所以ans的初始值需要赋很大,比如17个9,<-__<-;
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
ll n,k,ans=9999999999999999;
ll calc(ll a,ll b)
{
ll cnt=0;
while(a) cnt+=a/b,a/=b;
return cnt;
}
void solve()
{
while(~scanf("%lld%lld",&n,&k))
{
ans=9999999999999999;
for(ll i=2;i*i<=k;i++)
{
ll cnt=0;
while(k%i==0) cnt++,k/=i;
if(cnt) ans=min(ans,calc(n,i)/cnt);
}
if(k>1) ans=min(ans,calc(n,k));
printf("%lld\n",ans);
}
return;
}
int main()
{
freopen("amstl.in","r",stdin);
freopen("amstl.out","w",stdout);
solve();
fclose(stdin);
fclose(stdout);
return 0;
}