PAT A1077. Kuchiguse (20/17)

本文介绍了一种算法,该算法能够从一组日语台词中找出角色特有的语气词(Kuchiguse)。通过对比每句话的结尾部分来寻找共同的模式,如果存在相同的语气词,则输出最长的共同语气词。

The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often exaggerated artistically in Anime and Manga. For example, the artificial sentence ending particle "nyan~" is often used as a stereotype for characters with a cat-like personality:

  • Itai nyan~ (It hurts, nyan~)
  • Ninjin wa iyada nyan~ (I hate carrots, nyan~)

    Now given a few lines spoken by the same character, can you find her Kuchiguse?

    Input Specification:

    Each input file contains one test case. For each case, the first line is an integer N (2<=N<=100). Following are N file lines of 0~256 (inclusive) characters in length, each representing a character's spoken line. The spoken lines are case sensitive.

    Output Specification:

    For each test case, print in one line the kuchiguse of the character, i.e., the longest common suffix of all N lines. If there is no such suffix, write "nai".

    Sample Input 1:
    3
    Itai nyan~
    Ninjin wa iyadanyan~
    uhhh nyan~
    
    Sample Output 1:
    nyan~
    
    Sample Input 2:
    3
    Itai!
    Ninjinnwaiyada T_T
    T_T
    
    Sample Output 2:
    nai
    #include <cstdio>
    #include <algorithm>
    #include <cmath>
    #include <cstring>
    #define Max 300
    using namespace std;
    struct user
    {
    	char name[11];
    	char pas[11];
    }a[Max],b[Max];
    char getc(char a[],int m)
    {
    	return a[strlen(a)-1-m];
    }
    int main()
    {
    	char la[Max][Max];
    	int n,k=0,f=1;
    	scanf("%d",&n);
    	getchar();
    	for(int i=0;i<n;i++){
    		
    		gets(la[i]);
    	}
    	while (f==1){
    	for(int i=0;i<n-1;i++)
    	{
    		if(getc(la[i+1],k)!=getc(la[i],k)){
    			f=0;
    			break;
    		}
    	}
    	  if(f==1)  k++;
    	  else break;
    	}
    	if(k==0) printf("nai\n");
    	else {
    		for(int i=strlen(la[0])-k;i<strlen(la[0]);i++)
    			printf("%c",la[0][i]);
    	}
    	system("pause");
    	return 0;
    }
    

在使用 Git 进行远程仓库操作时,如果遇到 `remote: HTTP Basic: Access denied` 和 `fatal: Authentication failed` 错误提示,通常表明身份验证失败。这可能是由于密码或 Token 错误导致的。以下是可能的原因和解决方案: ### 原因分析 1. **密码过期或错误**:如果 Git 服务器启用了两步验证(2FA),则传统的用户名和密码验证方式不再适用,需要使用个人访问令牌(Personal Access Token, PAT)进行身份认证 [^1]。 2. **未正确配置 Git 凭据**:在某些情况下,Git 会缓存错误的凭据,导致后续操作失败。 3. **HTTPS 配置问题**:使用 HTTPS 方式访问 Git 仓库时,若未正确配置身份验证信息,也可能导致访问被拒绝。 ### 解决方案 #### 1. 使用 Personal Access Token (PAT) 替代密码 对于启用了两步验证(2FA)的 Git 服务器(如 GitHub、GitLab 等),建议使用 **Personal Access Token** 替代密码进行身份验证。 - 登录 Git 服务器,进入账户设置。 - 生成一个新的 Personal Access Token。 - 使用 Token 作为密码进行身份验证,例如在克隆仓库时: ```bash git clone https://<username>:<token>@github.com/<username>/<repository>.git ``` #### 2. 清除 Git 缓存的错误凭据 如果 Git 缓存了错误的凭据,可以通过以下命令清除缓存并重新输入正确的凭据: ```bash git credential-cache exit ``` 或者,如果使用的是 Windows 系统,可以通过“凭据管理器”删除旧的 Git 凭据,然后重新尝试操作。 #### 3. 配置 Git 凭据存储 为了减少重复输入凭据的麻烦,可以配置 Git 使用凭据存储机制: ```bash git config --global credential.helper store ``` 执行上述命令后,Git 会在首次操作时提示输入用户名和密码,并将其存储在本地文件中。 #### 4. 检查 HTTPS 配置 确保 Git 的 HTTPS 配置正确,可以通过以下命令检查当前配置: ```bash git config --global https.sslVerify ``` 如果返回 `false`,则需要重新启用 SSL 验证: ```bash git config --global https.sslVerify true ``` #### 5. 使用 SSH 替代 HTTPS 如果 HTTPS 方式持续出现问题,可以考虑使用 SSH 方式访问 Git 仓库。首先生成 SSH 密钥对,然后将公钥添加到 Git 服务器: ```bash ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` 生成密钥后,将公钥(通常为 `~/.ssh/id_rsa.pub`)添加到 Git 服务器的 SSH 密钥设置中。 ### 验证解决方案 完成上述配置后,再次尝试克隆或推送操作,确认是否解决了身份验证失败的问题。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值