CF—98A—Help Victoria the Wise
来源:互联网 发布:java虚拟主机管理系统 编辑:程序博客网 时间:2024/06/06 02:42
Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open the box. She hopes that you can help her in that.
The box's lock is constructed like that. The box itself is represented by an absolutely perfect black cube with the identical deepening on each face (those are some foreign nanotechnologies that the far away kingdom scientists haven't dreamt of). The box is accompanied by six gems whose form matches the deepenings in the box's faces. The box can only be opened after it is correctly decorated by the gems, that is, when each deepening contains exactly one gem. Two ways of decorating the box are considered the same if they can be obtained one from the other one by arbitrarily rotating the box (note that the box is represented by a perfect nanotechnological cube)
Now Vasilisa the Wise wants to know by the given set of colors the following: in how many ways would she decorate the box in the worst case to open it? To answer this question it is useful to know that two gems of one color are indistinguishable from each other. Help Vasilisa to solve this challenging problem.
The first line contains exactly 6 characters without spaces from the set {R,O,Y,G,B,V} — they are the colors of gems with which the box should be decorated.
Print the required number of different ways to decorate the box.
YYYYYY
1
BOOOOB
2
ROYGBV
30 //把每一种情况都列出来,挨个查找就可以了,共11种情况
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;void pan(int x,int y,int z){ if(x==1&&y==1&&z==1) printf("30\n"); else if(x==2&&y==1&&z==1) printf("15\n"); else if(x==3&&y==1&&z==1) printf("5\n"); else if(x==4&&y==1&&z==1) printf("2\n"); else if(x==5&&y==1) printf("1\n"); else if(x==6&&y==0) printf("1\n"); else if(x==2&&y==2&&z==1) printf("8\n"); else if(x==2&&y==2&&z==2) printf("6\n"); else if(x==3&&y==2) printf("3\n"); else if(x==4&&y==2) printf("2\n"); else if(x==3&&y==3) printf("2\n");}int main(){ char c[8]; int a[8]; while(scanf("%s",c)!=EOF) { memset(a,0,sizeof(a)); for(int i=0; i<strlen(c); i++) //R, O, Y, G, B, V { if(c[i]=='R') a[0]++; else if(c[i]=='O') a[1]++; else if(c[i]=='Y') a[2]++; else if(c[i]=='G') a[3]++; else if(c[i]=='B') a[4]++; else if(c[i]=='V') a[5]++; } sort(a,a+6); pan(a[5],a[4],a[3]); } return 0;}
- CF—98A—Help Victoria the Wise
- Help Victoria the Wise(cf 07/22/2011)
- A. Help Vasilisa the Wise 2
- A. Help Vasilisa the Wise 2 codeforces-problem-143A
- codeforce 143 A Help Vasilisa the Wise 2
- Codeforces 143A Help Vasilisa the Wise 2(暴力)
- code forces Help Vasilisa the Wise 2
- cf——A. The Great Game
- cf——A. Down the Hatch!
- CF:99A. Help Far Away Kingdom
- cf——#30A
- CF 340A The Wall
- Cf 406 A. The Monster
- CF——#109div1 A
- CF——#104div1 A
- cf——A. Unusual Product
- cf——A. Mashmokh and Lights
- 7.13——cf 304A
- 局域网中linux主机之间同步时间的一种笨方法
- Linux常用的网络命令
- Win32 结构化异常处理(SEH)探秘(续)
- hosts和hosts_backup有什么区别
- Spring AOP 详解
- CF—98A—Help Victoria the Wise
- 仓库和物品? 堆和栈!值类型和引用类型~~~~
- 指针和指针强制转换( 回忆版 )-------让初学者理解
- ATL_NO_VTABLE详解
- 设计模式(2)结合代码和例子来理解简单工厂模式
- 动态规划之最长子序列(线性)
- 附加数据库出错
- 完全卸载xcode
- allegro使用小技巧备忘录