Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
74689 | 邢逸轩 | 幸运数字 | C++ | Accepted | 100 | 128 MS | 256 KB | 457 | 2023-05-28 15:49:37 |
#include<bits/stdc++.h> using namespace std; string its(int a){ string s; while(a){ char c=a%10+'0'; s=c+s,a/=10; } return s; } int n,ans; int main(){ cin>>n; for(int i=1;i<=n;i++){ string s=its(i); if(i%4==0||i%7==0){ ans++; continue; } for(int j=0;j<s.size()-1;j++){ if( (s[j]=='4'&&s[j+1]=='4')|| (s[j]=='7'&&s[j+1]=='7') ){ ans++; break; } } } cout<<ans; return 0; }