提交时间:2021-05-16 16:53:48

运行 ID: 19540

#include <bits/stdc++.h> using namespace std; char str[10]={'0'}; int main() { int n,i,sum=0,j; cin>>n; for(i=1;i<=n;i++) { sprintf(str,"%d",i); if(i%4==0) { sum+=1; continue; } else if(i%7==0) { sum+=1; continue; } else { for(j=0;j<strlen(str);j++) { if(str[j]=='4'&&str[j+1]=='4') { sum+=1; break; } if(str[j]=='7'&&str[j+1]=='7') { sum+=1; break; } } } } cout<<sum<<endl; return 0; }