//WAかTLE #include using namespace std; int n; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int dfs(int num, int used) { if (num > n) { return 0; } int ret = dfs(num + 1, used); //数字numを使わない場合 int i; for (i = 2; i < num; i++) { if ((used >> i) % 2 == 1 && gcd(i, num) >= 2) { break; } } if (i == num) { //数字numを使う場合 ret = max(ret, num + dfs(num + 1, used + (1 << num))); } return ret; } signed main() { cin >> n; cout << dfs(2, 0) << endl; return 0; }