#include using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i> K; int ans = 0; string str = "12345678"; do{ int val = stoi(str); if(val % K == 0) ans++; }while(next_permutation(str.begin(), str.end())); cout << ans << endl; return 0; }