跳到正文

题解

CF98A 题解

ikunTLE约 2 分钟
原文
文章信息与版本

文章信息

发布
2024年10月7日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 2 分钟
获赞
11
题目
CF98A

版本

  1. v1当前

题目传送门

思路

首先统计出每种字母出现的次数,然后将得到的序列非 00 部分按升序排序。设这个序列为 AA,答案为 XX,打表得到的 1111 种情况分别是:

  • 当 A={6}A=\{6\} 时,X=1X=1。
  • 当 A={1,5}A=\{1,5\} 时,X=1X=1。
  • 当 A={2,4}A=\{2,4\} 时,X=2X=2。
  • 当 A={3,3}A=\{3,3\} 时,X=2X=2。
  • 当 A={1,1,4}A=\{1,1,4\} 时,X=2X=2。
  • 当 A={1,2,3}A=\{1,2,3\} 时,X=3X=3。
  • 当 A={2,2,2}A=\{2,2,2\} 时,X=6X=6。
  • 当 A={1,1,1,3}A=\{1,1,1,3\} 时,X=5X=5。
  • 当 A={1,1,2,2}A=\{1,1,2,2\} 时,X=8X=8。
  • 当 A={1,1,1,1,2}A=\{1,1,1,1,2\} 时,X=15X=15。
  • 当 A={1,1,1,1,1,1}A=\{1,1,1,1,1,1\} 时,X=30X=30。

AC CODE

C++
#include<bits/stdc++.h>
using namespace std;
int read(){int x=0;char f=1,ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return x*f;}
const int N=2e6+10;
char s[10];
int tong[128],ans[N];
int main(){
	scanf("%s",s+1);
	for(int i=1;i<=6;++i)
		++tong[s[i]];
	int a[]={0,tong['R'],tong['O'],tong['Y'],tong['G'],tong['B'],tong['V'],0,0};
	sort(a+1,a+7);
	int x=0;
	for(int i=1;i<=6;++i)
		x=x*10+a[i];
	ans[6]=1;
	ans[15]=1; 
	ans[24]=2; 
	ans[33]=2;
	ans[114]=2;
	ans[123]=3;
	ans[222]=6;
	ans[1113]=5;
	ans[1122]=8;
	ans[11112]=15;
	ans[111111]=30;
	printf("%d\n",ans[x]);
	return 0;
}
原文