Seven Segment Display Time Limit: Seconds Memory Limit: KB A seven segment display, or seven segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays. Sev…
Seven Segment Display 思路: 经典数位dp 代码: #include<bits/stdc++.h> using namespace std; #define LL long long #define pb push_back #define mem(a,b) memset(a,b,sizeof(a)) ]={,,,,,,,,,,,,,,,}; ]; LL dp[][]; LL dfs(int pos,int sum,bool limit){ )return sum; if…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3962 题目大意: 有t组数据. 给你一个n,和8位的十六进制数st,还有一张表格,里面有每一个数字的消耗. 比如"5A8BEF67"的消耗为为5 + 6 + 7 + 5 + 5 + 4 + 6 + 3 = 41. 然后让你求[n,n+st-1]区间的所有的数字的消耗之和. 解题思路: 数位DP,用solve(x)求0~x的总消耗. lim=0xFFFF…
非常好的一个题,可以比赛时想到的状态太奇葩,不方便转移,就一直没能AC. 思路:dp(i, j)表示已经考虑了前i位,前i位的和为j的贡献.如果当前的选择一直是最大的选择,那么就必须从0~下一位的最大值之间选择,所以必须增加一个标记表示当前是否被限制.否则就可以从0~15中任选一个填充该位,这种情况就是可能被重复访问的,因为要填充剩下的位,每一位都能填0~15,所以记忆一下,当再次访问时就返回. AC代码 #include <cstdio> #include <cmath> #in…
题意:给一个16进制8位数,给定每个数字的贡献,问你贡献和. 思路:数位DP,想了很久用什么表示状态,看题解说用和就行,其他的都算是比较正常的数位DP. 代码: #include<iostream> #include<stdio.h> #include<cmath> #include<string> #include<queue> #include<set> #include<vector> #include<str…
传送门:Seven Segment Display 题意:求一个给定区间每个数字的消耗值的和: 思路:数位DP,有点区间和的思想,还有就是这个十六进制,可以用%llx读,还是比较难的: 还有就是到最大的 0xffffffff 后,会从新跳到0,这里要加上两段solve(ri)+solve(most)-solve(m-1): #include <iostream> #include <cstdio> #include <cstring> #include <algo…
地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3962 题目: A seven segment display, or seven segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix…
Seven Segment Display Time Limit: 1 Second      Memory Limit: 65536 KB A seven segment display, or seven segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix d…
Seven Segment Display Time Limit: 2 Seconds      Memory Limit: 65536 KB A seven segment display, or seven segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix…
题目链接:  http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3494 题目大意:给定一些被禁止的BCD码.问指定范围内不含有任何这些禁止的BCD码的数的个数. 解题思路: AC自动机部分: 首先insert这些被禁止的BCD码. 然后打一下自动机前后状态的转移的表,用BCD[i][j]表示自动机状态i时,下一个数字是j的自动机的下一个状态. 一开始我考虑最先dfs的位在自动机的位置,后来发现SB了.AC自动机有一个roo…
BCD Code Time Limit: 5 Seconds      Memory Limit: 65536 KB Binary-coded decimal (BCD) is an encoding for decimal numbers in which each digit is represented by its own binary sequence. To encode a decimal number using the common BCD encoding, each dec…
F(x) Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 382    Accepted Submission(s): 137 Problem Description For a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weight as F(x…
You are given two integers l l and r r (l≤r l≤r ). Your task is to calculate the sum of numbers from l l to r r (including l l and r r ) such that each number contains at most k k different digits, and print this sum modulo 998244353 998244353 . For…
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/J?&headNav=acm来源:牛客网 时间限制:C/C++ 8秒,其他语言16秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 NIBGNAUK is an odd boy and his taste is strange a…
Educational Codeforces Round 53 E. Segment Sum 题意: 问[L,R]区间内有多少个数满足:其由不超过k种数字构成. 思路: 数位DP裸题,也比较好想.由于没考虑到前导0,卡了很久.但最惨的是,由于每次求和的时候需要用到10的pos次幂,我是用提前算好的10的最高次幂,然后每次除以10往下传参.但我手贱取模了,导致每次除以10之后答案就不同余了,这个NC细节错误卡了我一小时才发现. 代码: #include<iostream> #include<…
https://vjudge.net/problem/ZOJ-3962 题意:有16种灯,每种灯的花费是灯管数目,代表0~F(十六进制),现在从x开始跳n-1秒,每一秒需要的花费是表示当前的数的花费之和,问n-1秒后这段时间的花费总共是多少.跳到FFFFFFFF之后会跳回00000000. 思路:怀疑人生的题目.如果从平时计算[L,R]的花费,就计算[0,R] - [0,L-1]这样的角度来看,就会好做很多.同样如果跳到1LL<<32之后回到0,也分段考虑.这样写一个函数就可以计算了. 考虑三…
身份证验证 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1611    Accepted Submission(s): 201 Problem Description 大学时代的小Q,是一个志向远大的热血青年,欲致力于国家网络建设.长年泡在电脑密集的地区潜心钻研以互联网为传输媒介,以个人计算机为终端,旨在实现休闲.交流.获得虚拟成就的…
迟到了一天的AC.... 思路: 先把单个素数 或着 两个素数能组成的情况预处理一下,然后对于给出的 n,拿第三个素数去和两个素数的情况匹配,最后要注意去重. 详情见代码. 因为手残少敲了一个 else ,Debug了一晚上... #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> using namespace std; const long long in…
Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboar…
题意: 剪一段丝带,对于剪完后的每一段丝带长度必须是a,b,c 输入丝带的长度  n 和  a  b  c 输出一个整数,代表最多能剪成多少段 样例输入 5 5 3 2 7 5 5 2 样例输出 2 2 解析: 完全背包啦..就是让求在背包正好装满的情况下 所获取的价值(分成的段数)最大 在要装当前容量 j 时,判断一下j-A [i] 这个容量是否存在...所以要把背包容量为0时初始化为1 因为0肯定可以装出来...然后用完全背包的思想一层层 向上推...最后要减去0时的那个1 附01背包的变形…
就是统计1~n中出现的各个数字的次数,当然是在16进制下. 不过有个区间问题的小技巧,统计从 [x,y] 可以转换成 从 [1,y] 减去 [1,x-1]. 不过要分类讨论一下,因为有可能会出现溢出,从ffffffff +1 得到 00000000 就是溢出了. 因为 n < 1e9 所以只会溢出一次. // 290ms #include<cstdio> #include<cmath> #include<cctype> ,,,,,,,, ,,,,,,,}; lon…
Kpop Music Party Time Limit: 2 Seconds      Memory Limit: 65536 KB Marjar University often hosts Kpop music festival. A Kpop music festival will last several days. During a Kpop festival, there will be a Kpop party every day. Kpop music is very popul…
正品的概率 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 848    Accepted Submission(s): 67 Problem Description 袋中有m枚正品硬币,n枚次品硬币(次品硬币两面都有国徽),在袋中任取一枚,将它投掷k次,已知每次得到的都是国徽,那么这枚硬币是正品的概率是多少?   Input 输入包含多…
Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboard with N rows and M columns. Every day after work, Edward will place…
数码管从某个状态顺序转移N个状态 计算总共有多少个数码管被点亮 N<=10^9 观察数码管的变化规律,有明显的周期和重复,利用这个性质,计算相对于初始状态,某一位上的某个状态重复了多少次,就可以在常数时间内求得. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<vector> #include<queue> #inc…
/* 后天就要复赛了啊啊啊啊啊. 可能是因为我是一个比较念旧的人吧. 讲真 还真是有点不舍. 转眼间一年的时间就过去了. 2015.12-2016.11. OI的一年. NOIP gryz RP++. */ 水灾(sliker.cpp/c/pas) 1000MS 64MB 大雨应经下了几天雨,却还是没有停的样子.土豪CCY刚从外地赚完1e元回来,知道不久除了自己别墅,其他的地方都将会被洪水淹没. CCY所在的城市可以用一个N*M(N,M<=50)的地图表示,地图上有五种符号:". * X…
称号:ZOJ Problem Set - 2563 Long Dominoes 题意:给出1*3的小矩形.求覆盖m*n的矩阵的最多的不同的方法数? 分析:有一道题目是1 * 2的.比較火.链接:这里 这个差点儿相同,就是当前行的状态对上一行有影响.对上上一行也有影响.所以 定义状态:dp[i][now][up]表示在第 i 行状态为now .上一行状态为 up 时的方案数. 然后转移方程:dp[i][now][up] = sum ( dp[i-1][up][uup] ) 前提是合法 合法性的推断…
poj 2096 题目:http://poj.org/problem?id=2096 f[ i ][ j ] 表示收集了 i 个 n 的那个. j 个 s 的那个的期望步数. #include<cstdio> #include<cstring> #include<algorithm> #define db double using namespace std; ; db n,s,f[N][N]; int main() { scanf("%lf%lf"…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6212 解法:看了眼题就发现这个BZOJ 1032不是一毛一样?但是BZOJ上那是个巨坑,数据有错,原来A的是一个假题..2333,但是我并不知道POJ上也有这个题2333...网赛现场没做出来,感觉现场做出来的很多都知道这个题是原题吧..参考这个论文:http://www.docin.com/p-685411874.html 解法:这个题主要是区间DP的转移怎么写? 有三种消除方式: 1.直接将区间…
K - Watermelon Full of Water Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3632 Appoint description:   Description Watermelon is very popular in the hot summer. Students in ZJU-ICPC Team also lo…