Guest User

Untitled

a guest
Dec 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. #define rep(i,n) for(int i=0;i<n;++i)
  5. using namespace std;
  6. template<class T> void p(T a){cout << a << endl;}
  7. template<class T> void pp(T &a,int p){rep(i,p)cout << a[i] <<" ";cout << endl;}
  8.  
  9. long long int ans = 0;
  10.  
  11. void solve(vector<int> &dg, int n, int ps[]){
  12. if(dg[0] == 0) return;
  13. rep(i,7){
  14. if ((dg[1+i] * 100 + dg[2+i] * 10 + dg[3+i]) % ps[i] != 0) return;
  15. }
  16. rep(i,10){
  17. ans += dg[9-i] * pow(10.0, i);
  18. }
  19. }
  20.  
  21. int main(){
  22. int ps[] = {2, 3, 5, 7, 11, 13, 17};
  23. vector<int> dg;
  24. int n = 10;
  25. for(int i=0; i<10; i++) dg.push_back(i);
  26. do {
  27. solve(dg, n, ps);
  28. } while (next_permutation(dg.begin(), dg.end()));
  29. p(ans);
  30. return 0;
  31. }
Add Comment
Please, Sign In to add comment