Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rv地址翻译 #4

Open
Reisen1969 opened this issue Aug 10, 2022 · 9 comments
Open

rv地址翻译 #4

Reisen1969 opened this issue Aug 10, 2022 · 9 comments

Comments

@Reisen1969
Copy link
Owner

image

@Reisen1969
Copy link
Owner Author

image

@Reisen1969
Copy link
Owner Author

image

@Reisen1969
Copy link
Owner Author

╭╮╱╱╭━━┳━╮╱╭┳━╮╭━┳━━┳━╮╱╭┳━━┳━━━━╮
┃┃╱╱╰┫┣┫┃╰╮┃┣╮╰╯╭┻┫┣┫┃╰╮┃┣┫┣┫╭╮╭╮┃
┃┃╱╱╱┃┃┃╭╮╰╯┃╰╮╭╯╱┃┃┃╭╮╰╯┃┃┃╰╯┃┃╰╯
┃┃╱╭╮┃┃┃┃╰╮┃┃╭╯╰╮╱┃┃┃┃╰╮┃┃┃┃╱╱┃┃
┃╰━╯┣┫┣┫┃╱┃┃┣╯╭╮╰┳┫┣┫┃╱┃┃┣┫┣╮╱┃┃
╰━━━┻━━┻╯╱╰━┻━╯╰━┻━━┻╯╱╰━┻━━╯╱╰╯

@Reisen1969
Copy link
Owner Author

██╗░░░░░██╗███╗░░██╗██╗░░██╗██╗███╗░░██╗██╗████████╗
██║░░░░░██║████╗░██║╚██╗██╔╝██║████╗░██║██║╚══██╔══╝
██║░░░░░██║██╔██╗██║░╚███╔╝░██║██╔██╗██║██║░░░██║░░░
██║░░░░░██║██║╚████║░██╔██╗░██║██║╚████║██║░░░██║░░░
███████╗██║██║░╚███║██╔╝╚██╗██║██║░╚███║██║░░░██║░░░
╚══════╝╚═╝╚═╝░░╚══╝╚═╝░░╚═╝╚═╝╚═╝░░╚══╝╚═╝░░░╚═╝░░░

@Reisen1969
Copy link
Owner Author

░█─── ▀█▀ ░█▄─░█ ▀▄░▄▀ ▀█▀ ░█▄─░█ ▀█▀ ▀▀█▀▀
░█─── ░█─ ░█░█░█ ─░█── ░█─ ░█░█░█ ░█─ ─░█──
░█▄▄█ ▄█▄ ░█──▀█ ▄▀░▀▄ ▄█▄ ░█──▀█ ▄█▄ ─░█──

@Reisen1969
Copy link
Owner Author


| | |_ | \ | \ \ / / | \ | | |_ |
| | | | | | |\ V / | | | | | | | | |
| | | | | . | > < | | | . | | | | |
| |
__ | || |\ |/ . \ | || |\ || | | |
|||| _// ___|| _|_____| ||

@Reisen1969
Copy link
Owner Author

image

@Reisen1969
Copy link
Owner Author

import java.util.Scanner;

/**

  • Created with IntelliJ IDEA.

  • Author: Amos

  • E-mail: [email protected]

  • Date: 2022/12/16

  • Time: 21:47

  • Description:
    */
    public class Main0177 {
    public static void main(String[] args) {
    try (Scanner scanner = new Scanner(System.in)) {
    String text1 = scanner.nextLine();
    String text2 = scanner.nextLine();
    String res = solution(text1, text2);
    System.out.println(res);
    }
    }

private static String solution(String text1, String text2) {
char[] s1 = text1.toCharArray();
char[] s2 = text2.toCharArray();
int[][] dp = new int[s1.length + 1][s2.length + 1];
int maxLen = 0;
int lastPos = 0;
for (int i = 0; i < s1.length; i++) {
for (int j = 0; j < s2.length; j++) {
if (s1[i] == s2[j]) {
dp[i + 1][j + 1] = dp[i][j] + 1;
if (dp[i + 1][j + 1] > maxLen) {
maxLen = dp[i + 1][j + 1];
lastPos = i;
}
}
}
}
if (maxLen == 0) {
return "";
} else {
return text1.substring(lastPos - maxLen + 1, lastPos + 1);
}
}
}

@Reisen1969
Copy link
Owner Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant