题目链接:http://codeforces.com/contest/98/problem/A

题意大意:给你6种颜色,这6种颜色可能相同也可能不同,把这几种颜色全涂在一个正方体表面,问有多少种涂法(翻转后相同算作一种)。

思路:开始枚举全排列枚举所有情况,然后dfs,发现搜出来答案少了,最后发现少考虑了情况,只考虑了固定原始上表面然后顺时针旋转和另外五个面向上翻转,没有考虑另外五个面向上翻转后顺时针转动的情况。。

正解:先固定正方体,全排列枚举所有涂的情况,进行标记,然后再对枚举的每一种情况进行处理标记,翻转了和不翻转考虑为一种,枚举的每一种情况都有24种翻转情况,都要考虑清楚,如何枚举?先固定上下表面,朝一个方向转动,有4种,有6个面可以固定在上面,总共有4*6=24种。全排列开始我用6个for循环,太笨了,可以排序后调用函数,嘎嘎。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std; int pp[][]=
{
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,
}; int main()
{
string s;
while(cin >> s)
{
map<string,int>mp;
sort(s.begin(),s.end());
int ans=;
do
{
if(!mp[s])
{
mp[s]=;
ans++;
for(int i=; i<; i++)
{
string ss="";
for(int j=; j<; j++) ss+=s[ pp[i][j] ];
mp[ss]=;
}
}
}while(next_permutation(s.begin(),s.end())); ///用这个必须先排序
cout <<ans <<endl;
}
}

Codeforces Beta Round #78 Div. 1 A的更多相关文章

  1. Codeforces Beta Round #70 (Div. 2)

    Codeforces Beta Round #70 (Div. 2) http://codeforces.com/contest/78 A #include<bits/stdc++.h> ...

  2. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  3. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  4. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  5. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  7. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  8. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  9. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

随机推荐

  1. java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory 解决方案

    缺少 commons-logging.jar

  2. JMeter参数化(一)

    JMeter参数化的4种方法:

  3. loadrunner选择执行哪个Action

    深圳湖北籍软件测试群 275212937

  4. 《DSP using MATLAB》示例Example4.7

    ROC分三种情况:

  5. vim使用01

    安装与基础配置 iTerm快捷操作 清屏: <C l>/<W k> 剪切: <W x> 复制: <W v> 新增窗口: <W d> 切换窗口 ...

  6. zepto的bug2

    zepto的animate()源码采用css3的方式进行,而scrollTop属性不在css3的动画属性中,所以zepto不支持animate({scrollTop:"100px" ...

  7. 学习 Message(5): 关于 TApplicationEvents.OnMessage 的第二个参数 可以屏蔽 TWebBrowser右键菜单:

    http://www.cnblogs.com/del/archive/2008/10/25/1319318.html TApplicationEvents.OnMessage 的第二个参数 Handl ...

  8. zoom作用

    转自:http://www.cnblogs.com/top5/archive/2011/07/11/2103343.html css中的zoom的作用1.检查页面的标签是否闭合不要小看这条,也许折腾了 ...

  9. MACD 基本用法

    基本用法 1. MACD 金叉:DIFF 由下向上突破 DEA,为买入信号. 2. MACD 死叉:DIFF 由上向下突破 DEA,为卖出信号. 3. MACD 绿转红:MACD 值由负变正,市场由空 ...

  10. MFC HTTP访问URL

    unsigned short nPort; //用于保存目标HTTP服务端口 CString strServer, strObject; //strServer用于保存服务器地址,strObject用 ...