-
Notifications
You must be signed in to change notification settings - Fork 0
/
43.cpp
37 lines (34 loc) · 875 Bytes
/
43.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <cstdio>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
stringstream stream;
string s("0123456789");
inline unsigned long long Trans(const string & x)
{
stream << x; unsigned long long y;
stream >> y; stream.clear();
return y;
}
inline bool Judge(const string & get)
{
if (Trans(get.substr(1, 3)) % 2 != 0)return 0;
if (Trans(get.substr(2, 3)) % 3 != 0)return 0;
if (Trans(get.substr(3, 3)) % 5 != 0)return 0;
if (Trans(get.substr(4, 3)) % 7 != 0)return 0;
if (Trans(get.substr(5, 3)) % 11 != 0)return 0;
if (Trans(get.substr(6, 3)) % 13 != 0)return 0;
if (Trans(get.substr(7, 3)) % 17 != 0)return 0;
return 1;
}
int main()
{
ios::sync_with_stdio(false);
unsigned long long sum = 0;
while (next_permutation(s.begin(), s.end()))
if (Judge(s)) sum += Trans(s);
cout << sum << endl;
return 0;
}