sums[] = { 223, 224, 225, 225, 226, 226, 227, 227, 228, 229 } nums[n] = { 111, 112, 113, 114, 115 } a + b = 223 a + c = 224 a + d = 225 a + e = 226 b + c = 225 // 打破了第2条假设,不是按升序排序!
publicstatic String solution(int n, int[] sums) { ans = "Impossible"; fullArrange(sums, 0, n); // System.out.println(ans); return ans; } privatestaticvoidcheck(int n, int[] sums) { int[] nums = newint[n]; nums[0] = (int) Math.round((sums[0] + sums[1] - sums[n-1]) / 2.0); for (inti=1; i < n; i += 1) { nums[i] = sums[i-1] - nums[0]; } for (inti=0, k = 0; i < n; i += 1) { for (intj= i+1; j < n; j += 1) { if (nums[i] + nums[j] != sums[k++]) { return; } } } StringBuilderresult=newStringBuilder(); Arrays.sort(nums); for (int num: nums) { result.append(num + " "); } ans = newString(result.deleteCharAt(result.length()-1)); }
// 全排列,确定sums第k位的值 privatestaticvoidfullArrange(int[] sums, int k, int n) { if (k == sums.length) { check(n, sums); return; } for (inti= k, l = sums.length; i < l; i += 1) { swap(sums, i, k); fullArrange(sums, k + 1, n); swap(sums, i, k); } } privatestaticvoidswap(int[] a, int i, int j) { intt= a[i]; a[i] = a[j]; a[j] = t; } }
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then _OLD_VIRTUAL_PS1="${PS1-}" PS1="\n(${VIRTUAL_ENV_PROMPT}) ${PS1-}"# 添加换行符 export PS1 fi
MSYS2显示git prompt
# etc/profile.d/git-prompt.sh iftest -f /etc/profile.d/git-sdk.sh then TITLEPREFIX=SDK-${MSYSTEM#MINGW} else TITLEPREFIX=$MSYSTEM fi iftest -f ~/.config/git/git-prompt.sh then . ~/.config/git/git-prompt.sh else PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]'# set window title PS1="$PS1"'\n'# new line PS1="$PS1"'\[\033[32m\]'# change to green PS1="$PS1"'\u@\h '# user@host<space> PS1="$PS1"'\[\033[35m\]'# change to purple PS1="$PS1"'$MSYSTEM '# show MSYSTEM PS1="$PS1"'\[\033[33m\]'# change to brownish yellow PS1="$PS1"'\w'# current working directory iftest -z "$WINELOADERNOEXEC" then GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)" COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}" COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}" COMPLETION_PATH="$COMPLETION_PATH/share/git/completion" iftest -f "$COMPLETION_PATH/git-prompt.sh" then . "$COMPLETION_PATH/git-completion.bash" . "$COMPLETION_PATH/git-prompt.sh" PS1="$PS1"'\[\033[36m\]'# change color to cyan PS1="$PS1"'`__git_ps1`'# bash function fi fi PS1="$PS1"'\[\033[0m\]'# change color PS1="$PS1"'\n'# new line PS1="$PS1"'$ '# prompt: always $ fi MSYS2_PS1="$PS1"# for detection by MSYS2 SDK's bash.basrc # Evaluate all user-specific Bash completion scripts (if any) iftest -z "$WINELOADERNOEXEC" then for c in"$HOME"/bash_completion.d/*.bash do # Handle absence of any scripts (or the folder) gracefully test ! -f "$c" || . "$c" done fi
WARNING: Unknown module: java.rmi specified to --add-opens Exception in thread "main" java.lang.NoClassDefFoundError: java/util/logging/Logger at org.apache.juli.logging.DirectJDKLog.<init>(DirectJDKLog.java:61) at org.apache.juli.logging.DirectJDKLog.getInstance(DirectJDKLog.java:181) at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:133) at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:156) at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:211) at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:49) Caused by: java.lang.ClassNotFoundException: java.util.logging.Logger at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ... 6 more