题解 | #挑7#
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
#include <iostream> using namespace std; bool find7(int n){ if(n%7==0)return true; while(n){ if(n%10==7)return true; n = n/10; } return false; } int ans(int n){ int res=0; for(int i=7; i<=n;i++){ if(find7(i))res++; } return res; } int main() { int n; cin>>n; cout<<ans(n); } // 64 位输出请用 printf("%lld")