UVA 253 Cube painting(暴力打表)】的更多相关文章

Cube painting Problem Description: We have a machine for painting cubes. It is supplied with three different colors: blue, red and green. Each face of the cube gets one of these colors. The cube's faces are numbered as in Figure 1. Figure 1. Since a…
习题4-4 骰子涂色(Cube painting, UVa 253) 输入两个骰子,判断二者是否等价.每个骰子用6个字母表示,如图4-7所示. 图4-7 骰子涂色 例如rbgggr和rggbgr分别表示如图4-8所示的两个骰子.二者是等价的,因为图4-8(a) 所示的骰子沿着竖直轴旋转90°之后就可以得到图4-8(b)所示的骰子. (a) (b) 图4-8 旋转前后的两个骰子 . Sample Input rbgggrrggbgr rrrbbbrrbbbr rbgrbgrrrrrg Sample…
题意: 按如图的顺序给定2个骰子的颜色(只有r.b.g三种颜色) 问2个骰子是否一模一样 如 可表示为“rbgggr” 和 “rggbgr”, 第二个就是绕着Z轴顺时针旋转90度与第一个相同的骰子. 分析: 记录一个错误的做法:并不是只要两面两面互相映射, 如rbrggb 与 rgrgbb, 即使 rb 对应 rb.gb 对应 bg. rg对应rg, 但他们并不是一模一样的骰子.(可以借助真正的骰子旋转尝试一下,就是123456 和 153426, 想象一下2与5互换, 根本不可能从原来的骰子转…
大致题意:有三种颜色,一个立方体6面都可以涂一种颜色.现在给出两个每个面都涂好颜色的立方体,判断这两个立方体通过旋转是否相等. 立方体的旋转出来的结果有很多,首先可以0,1,2,3,4,5(顺序是:上前左右后下)中的任意一面为顶,然后垂直的四个面都可以朝前. 例如:0为上(则下必为5),则旋转后可以得到以下结果: 上 前 左 右 后 下 0  1  2  3  4  5 0  2  4  1  3  5 0  4  3  1  2  5 0  3  1  4  2  5 总共4种情况.六个面也就…
题意:输入两个骰子,判断是否等价 因为每一个面可以作顶面,共6*4种情况,枚举就可以了 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include<queue> #include<algorithm> #de…
UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 XOR的性质 GCD 由于题目只给出一个n,我们要求对数,能做的也始终暴力枚举a,b,这样就有n^2的复杂度,由于n很大,根本过不了. 于是我们就想用到其中一些性质,如XOR 与GCD,不妨假设 a xor b = c,并且根据题意还知道, gcd(a,b) = c,也就说明c一定是a的因子,所以在枚举的…
///找到一个数字序列包含所有n位数(连续)一次且仅一次 ///暴力打表 ///Time:141Ms Memory:2260K #include<iostream> #include<cstring> #include<cstdio> using namespace std; #define MAX 1000010 bool v[MAX]; char num[6][MAX]; int main() { //freopen("in.txt", &quo…
 Cube painting  We have a machine for painting cubes. It is supplied withthree different colors: blue,red and green. Each face of the cube gets oneof these colors. The cube's faces arenumbered as in Figure 1. Figure 1. Since a cube has 6 faces, our m…
Problem Description Recently, Mr. Xie learn the concept of happy number. A happy number is a number contain all digit 7 or only 1 digit other than 7. For example, 777 is a happy number because 777 contail all digit 7, 7177 and 87777 both happy number…
转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html    ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这么一说大家心里肯定有数了吧,“不就是next数组性质的应用嘛”,没错,正是如此. 在ACM的比赛中有些时候会遇到一些题目,可以或必须通过找出数据的规律来编写代码,这里我们专门来讨论下 如何运用KMP中next数组的性质 来寻找一个长数组中的最小循环周期. 先来看一道题 ZOJ 3785 What d…
u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 46844    Accepted Submission(s): 21489 Problem Description A simple mathematical formula for e is where n is allowed to go to infini…
题意 给出一个二进制数\(n\),每次操作可以将一个整数\(x\)简化为\(x\)的二进制表示中\(1\)的个数,如果一个数简化为\(1\)所需的最小次数为\(k\),将这个数叫做特殊的数, 问从\(1\)到\(n\)一共有多少个特殊的数,答案对\(1e9+7\)取模. 分析 \(n\)最大为\(2^{1000}\),二进制表示中最多有\(1000\)个\(1\),所以\(n\)以内的数经过一次简化后将变为\(1000\)以内的数,我们可以暴力打表\(1000\)以内的数简化为\(1\)所需的最…
UVA.10305 Maximum Product (暴力) 题意分析 直接枚举起点和重点,然后算出来存到数组里面,sort然后取最大值即可. 代码总览 #include <iostream> #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <sstream> #include <set> #inc…
Paula and Tai are couple. There are many stories between them. The day Paula left by airplane, Tai send one message to telephone 2200284, then, everything is changing- (The story in "the snow queen"). After a long time, Tai tells Paula, the numb…
UVa 253 #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <cmath> #include <sstream> #include <algorithm> #include <set> #include <map> #include <vector> #includ…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1216 Assistance Required Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3158    Accepted Submission(s): 1662 Problem Description After the 1997/19…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2089 有两种方法: 1.数位DP算法 2.暴力打表——真是个好法子!!! 接下来是注意点: 1.一般这种数组中的一个数减去一个数组的另一个数,sum[i]-sum[j],这时候就要注意是sum[i]-sum[j]还是sum[i]-sum[j-1] 2.打表就不要进行多余的循环和语句 题目代码: #include<iostream> using namespace std; ]={}; int so…
beautiful number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 801    Accepted Submission(s): 518 Problem Description Let A=∑ni=1ai∗10n−i(1≤ai≤9)(n is the number of A's digits). We call A as “…
这题开始想时,感觉给的范围5 <= a < b <= 100,000,000太大,开数组肯定爆内存,而且100000000也不敢循环,不超时你打我,反正我是不敢循环. 这题肯定得打表,筛素数肯定用埃托色尼筛法(不好意思把大名鼎鼎的埃拉托色尼名字打错了,表打我). 再看当你所找的回文数的位数为偶数时,有如下定理除11外所有偶数位数的回文数都能被11整除,所以所有偶数位数的回文都不是素数. 证明看如下(我手写的) 手机像素渣(凑活着吧)字丑也凑和着. 证完后我们在来说题目给的数据范围 所以当…
 We have a machine for painting cubes. It is supplied with three different colors: blue, red and green. Each face of the cube gets one of these colors. The cube's faces are numbered as in Figure 1.  Since a cube has 6 faces, our machine can paint a f…
题目描述:算法竞赛入门习题4-4  题目思路:1.旋转其中一个骰子进行匹配 2.进行遍历,如果匹配,就进行相对面的匹配 3.三个对立面都匹配即是一样等价的 //没有按照原题的输入输出 #include <stdio.h> int main(int argc, char *argv[]) { ],s1[],s2[]; while(scanf("%s",a) != EOF){ ;i<;i++){ s1[i] = a[i] ; s1[i] = a[i+] ; } int m…
题目大意 输入有三种颜色判断两个骰子是否相同 思路(借鉴) ①先用string输入那12个字符,然后for出两个骰子各自的字符串 ②这里用的算法是先找出第一个的三个面与第二个的六个面去比较,如果找到相同的面并且他们的对面相等那么继续寻找,直到三个面都能找到相对立的面 ③如果有一个面没有找到相等的面或者相等的对面之类的那么就break循环然后直接判断FALSE如果三个面都能满足上述条件,那么就是TRUE 代码 #include <bits/stdc++.h> using namespace st…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 绕(x,y,z)三个轴旋转. 枚举x,y,z各4次的结果. (4次之后能还原.可以方便上一层枚举下一个情况.) [代码] #include <bits/stdc++.h> #define rep1(i,a,b) for (int i = a;i <= b;i++) #define rep2(i,a,b) for (int i = a;i >= b;i--) using namespace std; const in…
管他什么rev数组,msg数组简化代码 #define _CRT_SECURE_NO_WARNINGS #include <cmath> #include <iostream> #include <stdio.h> #include<algorithm> #include <map> #include <cstring> #include <time.h> #include <string> using nam…
Division 紫书入门级别的暴力,可我还是写了好长时间 = = [题目链接]uva 725 [题目类型]化简暴力 &题解: 首先要看懂题意,他的意思也就是0~9都只出现一遍,在这2个5位数中. 接着,你要知道:枚举一个5位数就够了,不用2个5位数都枚举,因为你可以通过n知道第2个5位数. 最后set维护出现的次数,ok判断是否可行,pri输出. [时间复杂度]O(1e5) &代码: #include <bits/stdc++.h> using namespace std;…
Sheldon Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/H Description According to Sheldon Cooper, the best number is 73. In his own words, "The best number is 73. 73 is the 21st prime number. Its mirror, 37, is the 12th, and its m…
CardsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86686#problem/K Description You have N cards with different numbers on them. Your goal is to find a card with a maximal number. At the beginning a…
题目链接:hdu 5077 NAND 题目大意:Xiaoqiang要写一个编码程序,然后依据x1,x2,x3的值构造出8个字符.如今给定要求生成的8个字符.问 说Xiaoqiang最少要写多少行代码.代码内容仅仅能为NAND操作和return操作,操作的变量能够是常数. 解题思路:输入总共就256中情况,所以暴力剪枝打表,打表的代码手贱给删了...所以就将一下思路.开一个s数组 表示变量,然后相应每一层每次两个变量进行NAND操作. 大致三个剪枝,dfs时候,变量出现同样就跳过.8个字符能够直接…
option=com_onlinejudge&Itemid=8&category=516&page=show_problem&problem=3160" target="_blank" style="">题目连接:uva 12009 - Avaricious Maryanna 题目大意.给定n.求x.x为n位数,而且x*x的后n位还是x. 解题思路:打个表会发现事实上有规律,除了n=1的时候多了0和1.其它都是n-1位…
素数回文 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 23082    Accepted Submission(s): 5399 Problem Description xiaoou33对既是素数又是回文的数特别感兴趣.比如说151既是素数又是个回文.现在xiaoou333想要你帮助他找出某个范围内的素数回文数,请你写个程序找出 a…