暴力秒了
#include<bits/stdc++.h> #define int long long//开long long是个好习惯 using namespace std; bool baozi(int x) { while(x) { int t = x % 10; if(t == 2 || t == 0 || t == 1 || t == 9) //数位判断 { return true; } x /= 10; } return false; } signed main() { int n , sum = 0; cin >> n; for(int i = 1;i <= n;i++) { if(baozi(i))//如果条件成立, 就让sum加上i { sum += i; } } cout << sum << endl;//最后输出所有满足条件的数的和 return 0; }
但是写的数位dp做法调不出来
标签:P8680,return,tar,int,long,蓝桥,2019,include From: https://www.cnblogs.com/smartljy/p/18048186