【小米oj】 数7游戏

由于符合要求的数还是相当密集的,所以本题可以采取暴力,如果范围扩到1e18则可以数位dp

 1 #define mm(a) memset(a,0,sizeof(a));
 2 #define max(x,y) (x)>(y)?(x):(y)
 3 #define min(x,y) (x)<(y)?(x):(y)
 4 #define Fopen freopen("1.in","r",stdin); freopen("m.out","w",stdout);
 5 #define rep(i,a,b) for(ll i=(a);i<=(b);i++)
 6 #define per(i,b,a) for(ll i=(b);i>=(a);i--)
 7 #include<bits/stdc++.h>
 8 typedef long long ll;
 9 #define PII pair<ll,ll>
10 using namespace std;
11 const int INF=0x3f3f3f3f;
12 const int MAXN=(int)2e6+5;
13 
14 int n;
15 
16 bool ck(int x) {
17     if(x%7==0)return 0;
18     while(x) {
19         if(x%10==7)return 0;
20         x/=10;
21     }
22     return 1;
23 }
24 int main() {
25     while(~scanf("%d",&n)) {
26         int x=0;
27         while(n) {
28             x++;
29             if(ck(x))n--;
30         }
31         printf("%d
",x);
32     }
33     return 0;
34 }
原文地址:https://www.cnblogs.com/dogenya/p/10815696.html