ZOJ 3436 July Number(DFS)】的更多相关文章

题意   把一个数替换为这个数相邻数字差组成的数  知道这个数仅仅剩一位数  若最后的一位数是7  则称原来的数为 July Number  给你一个区间  求这个区间中July Number的个数 从7開始DFS  位数多的数总能由位数小的数推出 #include <bits/stdc++.h> using namespace std; const int N = 1e6; int july[N], n; set<int> ans; int pw[] = {1, 10, 100,…
题目大意: 将一个数字的相邻两位的差(的绝对值)组成一个新的数字.不断反复.假设最后得到7,就称这个数为July Number,比方9024 – 922 – 70 – 7. 题目要求1e9范围内给定区间[a, b]里July Number的个数. 思路:逆向递推,既然题目求能化成 7 的数的个数.那么就从 7 逆着找出去 18 .29.70,81.92等,(要注意的就是:还有从07,007.....等找出去的,每一个数同理: 代码: /* SKY */ #include<iostream> #…
题目:UVA10624 - Super Number(dfs) 题目大意:给你n和m要求找出这种m位数,从第n位到第m位都满足前i位是能够被i整除,假设没有这种数,输出-1.有多个就输出字典序最小的那个. 解题思路:将每一个位置都用0..9枚举一下,注意第一个字符不能是0,然后dfs推断每一个位置是否都满足要求.注意这里是会爆long long的,所以要取模一下.本来以为这种做法会超时的,结果居然过了,预计是例子数少,并且找不到的情况也比較少. 代码: #include <cstdio> #i…
题目传送门 /* 题意:n个时刻点,m次时光穿梭,告诉的起点和终点,q次询问,每次询问t时刻t之前有多少时刻点是可以通过两种不同的路径到达 思维:对于当前p时间,从现在到未来穿越到过去的是有效的值,排个序,从大到小询问,那么之前添加的穿越点都是有效的, 用multiset保存.比赛时想到了排序,但是无法用线段树实现查询,stl大法好! */ #include <cstdio> #include <algorithm> #include <cstring> #includ…
Generalized Palindromic Number Time Limit: 2 Seconds                                     Memory Limit: 65536 KB                             A number that will be the same when it is written forwards or backwards is known as a palindromic number. For…
Sum It Up Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 4   Accepted Submission(s) : 1 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Given a specified total t and…
Gnome Tetravex Time Limit: 10 Seconds      Memory Limit: 32768 KB Hart is engaged in playing an interesting game, Gnome Tetravex, these days. In the game, at the beginning, the player is given n*n squares. Each square is divided into four triangles m…
意甲冠军  两个农田管内可直接连接到壳体  他们将能够共享一个水源   有11种农田  管道的位置高于一定  一个农田矩阵  问至少须要多少水源 DFS的连通块问题  两个相邻农田的管道能够直接连接的话他们就属于一个连通块  题目就是求连通块个数 #include<cstdio> #include<cstring> using namespace std; const int N = 55; char mat[N][N]; int type[11][4] = { //相应11种水管…
Problem UVA11882-Biggest Number Accept: 177    Submit: 3117Time Limit: 1000 mSec    Memory Limit : 128MB Problem Description Input There will be at most 25 test cases. Each test begins with two integers R and C (2 ≤ R,C ≤ 15, R∗C ≤ 30), the number of…
题意 Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. 给定数字,输出所有可能的字母组合 解法 可以先将数字对应的字母存好,然后遍历输出就可以.只不过不用递归来写好像比较麻烦,这里用了一个DFS…