[C++]30分 #4~#10WA
  • 板块P1246 编码
  • 楼主RDFZchenyy
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/2/26 12:37
  • 上次更新2023/10/28 07:43:12
查看原帖
[C++]30分 #4~#10WA
567610
RDFZchenyy楼主2022/2/26 12:37
#include<bits/stdc++.h>
using namespace std;

int main(){
	long long use[26];
	memset(use,0,sizeof(use));
	int ans=1;
	int now_plus=0;
	char input,lst;
	bool is_word=true;
	int len=0;
	lst='a';
	while(cin>>input){
		if(input<'a'||input>'z'){
			is_word=false;
			break;
		}else if(input<=lst&&lst!='a'){
			is_word=false;
			break;
		}else if(len==6){
			is_word=false;
			break;
		}else{
			now_plus=0;
			use[input-'a']=true;
			for(int i=lst-'a';i<input-'a';i++){
				if(!use[i]){
					now_plus++;
				}
			}
			ans+=now_plus;
			ans*=26-len;
		}
		len++;
		lst=input;
	}
	ans/=26-len+1;
	if(len==1){
		ans--;
	}
	if(is_word){
		printf("%lld\n",ans+1);
	}else{
		printf("0\n"); 
	}
	
	return 0;
}
2022/2/26 12:37
加载中...