题解 | #挑7#
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
#include <algorithm> #include <iostream> using namespace std; int main() { int n; cin >> n; int t = 1; int cur = 0; int weight[5] = {1, 10, 100, 1000, 10000}; while (t <= n) { if(t % 7 == 0) { cur++; t++; continue; } for(int i = 0; i < 5; i++) { if((t / weight[i]) % 10 == 7) { cur++; break; } } t++; } cout << cur << endl; }