Codeforces Beta Round #78 Div. 1 A
题目链接: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的更多相关文章
- Codeforces Beta Round #70 (Div. 2)
Codeforces Beta Round #70 (Div. 2) http://codeforces.com/contest/78 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
随机推荐
- 战斗住的DPS才是DPS,持续的执行力才是执行力
工作久了,真的发现执行力这个东西太难被贯彻,计划时信心满满,冲劲十足,持续一段时间后就喇叭腔了.
- 00_Java基本常识
1. 基本常识 软件:一系列按照特定顺序组织的计算机数据和指令的集合. 常见的软件:系统软件 和 应用软件. 人机交互:图形化界面.命令行方式 计算机语言:人与计算机交流的方式 dos常见命令 ...
- JS实现选择不同select标签option值的验证
js实现不同select标签option值的验证 功能描述: 选择中文时,匹配中文的正则表达式,选择英文选项是匹配英文的表达式,并且有对应的提示信息. html代码片段: <select id= ...
- Collection与Map
20145217 <Java程序设计>第5周学习总结(2) 教材学习内容总结 程序中常有收集对象的需求 9.1collection架构 收集对象的行为,像是新增对象的add()方法.移除对 ...
- iOS 获取当前用户的用户路径并写入文件
NSString *path = [[@"~" stringByExpandingTildeInPath] stringByAppendingString: @"/tmp ...
- Android获取APK包名的几种方法
Android获取APK包名的几种方法:1.adb shell pm list package -f | findstr 关键字 #只能获取到包名,主Activity名无法获取到 2.使用aapt-- ...
- 类型“System.Windows.Markup.IQueryAmbient”在未被引用的程序集中定义
错误 1 类型"System.Windows.Markup.IQueryAmbient"在未被引用的程序集中定义.必须添加对程序集"System.Xaml, ...
- ural 2068. Game of Nuts
2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...
- Theano深度学习结构分析
Reference:Theano入门三部曲 http://deeplearning.net/tutorial/logreg.html (Softmax回归) http://deeplearning. ...
- 移动端 设计与开发经验之ViewPort
Viewport :字面意思为视图窗口,在移动 web 开发中使用.表示将设备浏览器宽度虚拟成一个特定的值(或计算得出),这样利于移动 web 站点跨设备显示效果基本一致. 基本写法: <met ...