题解 | #挑7#
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
#include <iostream> using namespace std; int main() { int n = 0; int ans = 0; cin >> n; for (int i = 1; i <= n; ++i) { if (i % 7 == 0) { ans++; } else { int j = i; while (j != 0) { if ((j % 10) == 7) { ans++; break; } else { j = j / 10; } } } } cout << ans << endl; return 0; }