P1151 子数整数
https://www.luogu.org/problem/show?pid=1151
预处理可行的数,枚举,分解,判断
#include<iostream> #include<cstdio> #include<math.h> #include<algorithm> #include<queue> using namespace std; int k; int main() { cin>>k; int t1,t2,t3; for(int i=10000;i<=30000;i++) { t1=i%1000;if(t1%k) continue; t3=i%10; t2=(i-t3)/10 ;t2=t2%1000;if(t2%k) continue; t2=i%100;t3=(i-t2)/100;t3=t3;if(t3%k) continue; printf("%d \n",i); } return 0; }