题解 | #挑7#
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ans = 0; int temp; for (int i = 1; i <= n; i++) { temp = i; if (temp % 7 == 0) { ans++; } else { while (temp > 0) { if (temp % 10 == 7) { ans++; break; } else temp = temp / 10; } } } cout << ans << endl; return 0; } // 64 位输出请用 printf("%lld")