- 博客(194)
- 收藏
- 关注
原创 Chisel Scala学习记录——查阅过的小知识点、小细节
一个讲的很详细的博客。chisel scala入门教程for中,使用to和until,for( i <- 1 to n) 包含n,for( i <- 1 until n) 不包含n。Nil是空List,::追加进入,Chisel的util包里定义了一个Enum特质及其伴生对象。伴生对象里的apply方法定义如下:def apply(n: Int):Lis...
2019-09-12 23:02:11 270
原创 AtCoder Beginner Contest 121
atcoder第二次AK,开心。过段时间稳定点开始AGC。AB读明白题就行,C简单拍个序。D题题意:计算A,A+1,…… ,B这些数的异或结果。思路:记f(a,b)为[a,b]内所有数的异或结果,则a>=1时f(a,b)=f(1,a-1)^f(1,b)。只要计算出1,2,……,n这些数的异或结果即可,记为g(n)当一个数为偶数,则这个数于比他大1的数异或值为1....
2019-03-10 00:19:26 525
原创 AtCoder Beginner Contest 115
虽然这次题目确实简单了点,但首次AK ATcoder ABC还是挺开心的。C - Christmas Eve排序然后遍历一遍计算出间隔k的最小差即可。#include<iostream>#include<cstdio>#include<algorithm>#include<cstdlib>int h[100005];using...
2018-12-08 22:10:22 258
原创 Codeforces Round #524 (Div. 2) C. Masha and two friends
题意:一个黑白格相间的矩阵,先给出一个子矩阵,全涂白,然后再给出一个矩阵,全涂黑。问最后白色和黑色的格子各有多少。思路:先计算出初始的两个颜色的格子数。计算涂白时候增加的白色格子,更新格子数,计算涂黑增加的黑色格子数,更新,然后在计算相交部分的。 写完以后觉得这么写还是有点麻烦,直接计算出来两个部分最后黑色和白色的格子数,总数上加加减减就好了,不过关键点都是一样的。关...
2018-11-26 10:05:26 158
原创 hdu1082 Matrix Chain Multiplication
居然读题读了这么久。。。一直不知道在问什么。。还是比较简单的,使用一个简单的栈,遇见字母就进栈,遇到“(”不用处理,用到“)”出栈两个元素,计算,然后加到sum上,然后更改行列数再放入栈中,直到字符串结束。#include<iostream>#include<map>#include<stack>#include<string>us...
2018-11-22 23:12:56 167
原创 hdu1018 Big Number
思路:设x是a的位数,则x=log10(a) + 1; 于是,结果就是log10(t!)+1=log10(t) + log10(t-1) + ... + log10(2) + 1#include <iostream>#include <cmath>using namespace std;int main(){ int n;...
2018-11-15 20:15:38 128
原创 hdu1249三角形
时间长了就容易忘,又复习了一遍https://blog.csdn.net/vinacky/article/details/8958326各种切割平面问题#include<iostream>using namespace std;int main(){ int t; cin>>t; while(t--) { ...
2018-11-09 10:54:25 137
转载 vivado timing report
转自:https://forums.xilinx.com/t5/Welcome-Join/Total-Negative-Slack-vs-Worst-Negative-Slack/td-p/308077 The "Worst Negative Slack (WNS)" reported by commands like report_timing_summary is actually...
2018-11-05 17:28:09 2094
原创 hdu1222 Wolf and Rabbit
题意:n个位置围成一圈,每次加m,问是否能遍历完所有的点思路:设位置下标为p,则存在k和x能使p+nk=xm成立。则m和n互质可以使得p从0到n-1都能取到。#include<iostream>using namespace std;int gcd(int m,int n){ while(m!=0) { int t=n%m; ...
2018-11-03 14:12:30 122
原创 hdu1443 Joseph
约瑟夫环问题的演变。题意:k个好人站前面,k个坏人站后面,排成2k的一列,报数每到m杀掉一个,最后要求剩下k个好人,问最小的m是多少。思路:因为k很小,但是查询次数多,所以打表,记录每个k的结果,每次杀掉一个人后,以下一个人为新的队列下标0,计算出来好人的开始和结束下标,以判断下次是否会杀到好人。#include<iostream>using namespace std...
2018-11-02 10:04:11 217
原创 hdu 1052 Tian Ji -- The Horse Racing
题目真的是有点长。题意:两组相同数量的数字,两两对比不能重复使用,如果第一组的一个大于第二组的一个则加200分,小于减200分,等于不加不减。思路:先将两组都按照从小到大进行排列,贪心的思路记下来第一组比第二组大的数量。具体就是,当成两个指针,分别表示当前比较位置,1. 如果第一个大于第二个则加分,两个指针均向后移动2. 如果第一个等于第二个,则可能是平,不计分,但相等的时...
2018-10-27 11:30:08 96
原创 【leetcode Weekly Contest 107】927. Three Equal Parts
Given an array A of 0s and 1s, divide the array into 3 non-empty parts such that all of these parts represent the same binary value.If it is possible, return any [i, j] with i+1 < j, such that:...
2018-10-21 14:56:51 235 2
原创 【leetcode Weekly Contest 107】926. Flip String to Monotone Increasing
A string of '0's and '1's is monotone increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possibly 0.)We are given a string S of '0's and '1's, and ...
2018-10-21 14:38:28 179
原创 【leetcode Weekly Contest 107】 925. Long Pressed Name
Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times.You examine the typed characte...
2018-10-21 13:19:10 160
原创 hdu1072 Nightmare(BFS)
这真的是几乎很标准的bfs迷宫题了。一点注意,可能一直可以重置时间,但是始终在里面循环无法出来,这种情况应该返回-1,我们需要避免这种情况,因为到达一个重置的地方,剩余步数是一样的,所以再次到这个位置无论如何都不会比第一次到更快的走出迷宫,所以第一次到达重置的位置后,将这个位置加入队列,然后将这个位置置0保证不再经过。#include<iostream>#include<...
2018-10-18 23:00:53 151
原创 hdu1728 逃离迷宫(BFS)
题意:经典的迷宫问题的基础上,条件是转弯次数的限制,最多k次转弯。对于这种情况,使用BFS不再是每次添加当前位置周围1步的点,而是将除了走过的以外三个方向上所有的点放入队列。跳入的坑比较多,因为懒,所以没有重新写,总是在之前的上面修修补补。添加点的时候,同一方向上,遇到*停止这个方向的添加,但是遇到添加过的点跳过这个点不添加,但继续向前。#include<iostream>...
2018-10-18 21:15:03 190
原创 hdu1003 Max Sum
题意:给出一串数字找出和最大的连续子序列,要求输出最大和及其起点和终点。如果有相同的和,输出第一个。思路:动态规划求解,sum保存以当前输入num值结尾的连续子序列的最大和,即两种情况,当前输入与前面的连山,或者当前输入自成子序列。再用一些变量保存临时的子序列开始和结尾即可。#include<iostream>using namespace std;int main()...
2018-10-11 22:40:47 94
原创 hdu1203 I NEED A OFFER!
http://acm.hdu.edu.cn/showproblem.php?pid=1203 一道简单的背包问题。但是,查了一晚上错。。没有考虑到内循环j=0的情况#include<iostream>#include<cstdio>#include<cstring>#include <iomanip>using namespac...
2018-10-10 09:31:25 96
原创 AtCoder Beginner Contest 112 D - Partition
被C题坑了,就没有再看D题,还是比较有意思的。Problem StatementYou are given integers N and M.Consider a sequence aa of length N consisting of positive integers such that a1+a2+...+aN = M. Find the maximum possible v...
2018-10-07 00:02:00 398
原创 AtCoder Beginner Contest 112 C - Pyramid
Problem StatementIn the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.The pyramid had center coordinates(CX,CY)and height ...
2018-10-06 23:30:06 664 2
原创 hdu1087 Super Jumping! Jumping! Jumping!
简单动态规划,从一串数字中找出最大升序数列的和。#include<iostream>using namespace std;int a[1005],b[1005];int main(){ int n; while(cin>>n) { if(n==0) break; for(int i=0;i<n;i++) ...
2018-09-30 16:50:05 84
原创 AtCoder Beginner Contest 110
第一场ATcoder就遇到测试样例出问题取消本场积分的事情,呜呜呜~~一份题解证明我来过!ABC水过前三道,排名575.上周的比赛,因为最后一题加上拖延症,还是终于在本周比赛开始前来写这个解题报告了。第一场体验还是不错的,后来发现有题解值得表扬A - Maximize the Formulahttps://beta.atcoder.jp/contests/abc110/tasks/a...
2018-09-29 16:10:04 677
转载 词法分析生成器flex的选项 %option
转自:https://blog.csdn.net/sever2012/article/details/7715176flex的选项影响最终生成的词法分析器的属性和行为。这些选项可以在运行flex命令时在终端输入,也可以在.l文件中使用%option指定。option的主要分类:Options for Specifying FilenamesOptions Affecting Sca...
2018-09-26 11:17:22 2596
原创 hdu2062 Subset sequence
#include<iostream>#include<cstdio>#include<vector>#include<cmath>using namespace std;long long f[25];int main(){ long long n,k; vector<int> v; f[1]...
2018-09-21 22:08:57 159
原创 hdu 1717 小数化分数2
Problem DescriptionRay 在数学课上听老师说,任何小数都能表示成分数的形式,他开始了化了起来,很快他就完成了,但他又想到一个问题,如何把一个循环小数化成分数呢?请你写一个程序不但可以将普通小数化成最简分数,也可以把循环小数化成最简分数。Input第一行是一个整数N,表示有多少组数据。每组数据只有一个纯小数,也就是整数部分为0。小数的位数不超过9位,循环部分用(...
2018-09-12 21:22:49 186
转载 acm题集
hduoj题目分类https://blog.csdn.net/hhu1506010220/article/details/52107420搜索题(100道)https://blog.csdn.net/coraline_m/article/details/11515057题集https://blog.csdn.net/helloworld19970916/article/deta...
2018-09-12 14:54:42 295
原创 hud2504 又见GCD
Problem Description有三个正整数a,b,c(0<a,b,c<10^6),其中c不等于b。若a和c的最大公约数为b,现已知a和b,求满足条件的最小的c。Input第一行输入一个n,表示有n组测试数据,接下来的n行,每行输入两个正整数a,b。Output输出对应的c,每组测试数据占一行。Sample Input2 6 2 12 4Samp...
2018-09-04 11:23:43 195
原创 hdu1722 Cake
Problem Description一次生日Party可能有p人或者q人参加,现准备有一个大蛋糕.问最少要将蛋糕切成多少块(每块大小不一定相等),才能使p人或者q人出席的任何一种情况,都能平均将蛋糕分食.Input每行有两个数p和q.Output输出最少要将蛋糕切成多少块.Sample Input2 3Sample Output4Hint将蛋糕切成大...
2018-08-31 11:33:19 145
原创 hdu2175 汉诺塔IX
http://acm.hdu.edu.cn/showproblem.php?pid=2175找找规律。我大概的思考过程是这样的:先写出来123456……表示第几次移动,然后在下面补充盘子号,先是1,然后2号,然后1号放2号上面,然后3号,将1、2放到3上面就是前面所有的盘子号再写一遍,然后写4,然后又是从第1个开始全部写一遍,就可以想到每次都是添加一个数再把前面的全部重复一遍。以上这些就联...
2018-08-30 21:29:02 172
原创 Codeforces Round #506 (Div. 3) D. Concatenated Multiples
http://codeforces.com/contest/1029/problem/D You are given an array a, consisting of n positive integers.Let's call a concatenation of numbers x and y the number that is obtained by writing down ...
2018-08-29 21:49:46 282
原创 Codeforces Round #506 (Div. 3) C. Maximal Intersection
http://codeforces.com/contest/1029/problem/CYou are given nsegments on a number line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can...
2018-08-29 21:26:12 114
原创 Codeforces Round #506 (Div. 3) B. Creating the Contest
You are given a problemset consisting of n problems. The difficulty of the i-th problem is ai. It is guaranteed that all difficulties are distinct and are given in the increasing order.You have to ...
2018-08-29 20:50:25 116
原创 Codeforces Round #506 (Div. 3) A. Many Equal Substrings
You are given a string t consisting of n lowercase Latin letters and an integer number k.Let's define a substring of some string swith indices from l to r as s[l…r]Your task is to construct suc...
2018-08-29 20:42:15 132
原创 hdu2077 汉诺塔IV
给传统汉诺塔问题加上了一些条件限制。1.只能从往相邻的柱子移动2.最大的盘子可以放在最上面思路:虽然只能往旁边的柱子移动,但依然有规律可循。最大的盘子可以放在最后单独考虑。计算将t个盘子移到旁边的柱子上最少步数记为f(t),则t+1个盘子的移动:先将t个盘子移到中间f(t)步,再将t个盘子移到最右f(t)步,将第t+1个移到中间1步,再将t个盘子移到第t+1个盘子上面f(t)步,至...
2018-08-24 11:32:56 213
原创 hdu2067 小兔的棋盘
思路:将棋盘画出来,先选择一半棋盘,比如上半部分,第0行的点都只有1条路径,第二行分别是1 2 3 4 5...1 1 1 1 1 1 1 1 2 3 4 5 6 2 5 9 14 20 5 14 28 4...
2018-08-23 17:53:23 134
原创 杭电hduoj 1996 汉诺塔VI
依旧水题每个盘子都有3个位置可选,在每个柱子上的排列顺序是一定的,所以一旦选定就是一种方式,所以n个盘子就会产生3^n种情况,输出就可以了 #include<iostream>#include<cstring>#include<vector>#include<cmath>#include<iomanip>usin...
2018-08-20 21:37:16 485
原创 杭电1995 汉诺塔V
2的多少次方,可以找找规律#include<iostream>#include<cstring>#include<vector>#include<cmath>#include<iomanip>using namespace std;int main(){ int t; cin>>t; whi...
2018-08-20 21:29:59 227
原创 杭电2093 考试排名 hduoj
完全按照题目描述写出来就行了,看着可能有些麻烦,其实还好,就是注意一下比较函数和输出格式。 #include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;struct student{ char name[...
2018-08-17 15:21:19 441
原创 google面试题
https://hjptriplebee.github.io/Google面试经历-一.html/ 看到上面这个博客中的一道面试题,如下有一个n*n的棋盘,上面有m个糖果,最开始有一个人在棋盘左上角,他可以向左向右或者向下移动,但不能向上移动,问他最少需要多少步吃完所有糖果。写一下自己的思路和代码,因为没有OJ可以验证,不知道对错,暂且记录一下。思路:动态规划求解动规计算如果从...
2018-08-15 10:58:06 694
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人