第一题、
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,t;
cin>>n;
for(int i=1;i<=n;i++)
{
if(i%5==0)
{
bool dc=false;
int s=i;
while(s!=0)
{
int r=s%10;
if(r==5)
{
dc=true;
}
s=s/10;
}
if(dc==true)
{
t++;
}
}
}
cout<<t<<endl;
system("pause");
return 0;
}
第二题、
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
float a=0;
float t=1;
while(a<=n)
{
a=a+1.0/t;
t++;
}
cout<<t-1<<endl;
system("pause");
return 0;
}