again

hdu 2057 A + B Again

感情迁移 提交于 2020-03-10 10:41:36
Problem Description There must be many A + B problems in our HDOJ , now a new one is coming. Give you two hexadecimal integers , your task is to calculate the sum of them,and print it in hexadecimal too. Easy ? AC it ! Input The input contains several test cases, please process to the end of the file. Each case consists of two hexadecimal integers A and B in a line seperated by a blank. The length of A and B is less than 15. Output For each test case,print the sum of A and B in hexadecimal in one line. Sample Input +A -A +1A 12 1A -9 -1A -12 1A -AA Sample Output 0 2C 11 -2C -90 解

1086 Tree Traversals Again (25分)

浪子不回头ぞ 提交于 2020-03-08 21:13:03
题目 An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stack operations are: push(1); push(2); push(3); pop(); pop(); push(4); pop(); pop(); push(5); push(6); pop(); pop(). Then a unique binary tree (shown in Figure 1) can be generated from this sequence of operations. Your task is to give the postorder traversal sequence of this tree. Input Specification: Each input file contains one test case. For each case, the first line contains a positive integer

Fire Again CodeForces - 35C (BFS)

心不动则不痛 提交于 2020-02-29 12:20:57
After a terrifying forest fire in Berland a forest rebirth program was carried out. Due to it N rows with M trees each were planted and the rows were so neat that one could map it on a system of coordinates so that the j -th tree in the i -th row would have the coordinates of ( i ,  j ). However a terrible thing happened and the young forest caught fire. Now we must find the coordinates of the tree that will catch fire last to plan evacuation. The burning began in K points simultaneously, which means that initially K trees started to burn. Every minute the fire gets from the burning trees to

Day11 - D - Race to 1 Again LightOJ - 1038

夙愿已清 提交于 2020-02-21 17:30:41
设dp_i为所求答案,每次选择因数的概率相同,设i有x个因数,dp_i=sum(1/x*x_j)+1,(x_j表示第j个因数),那我们就预处理每个数的因数即可,T=10000,需要预处理出答案 #include<bits/stdc++.h> using namespace std; #define lowbit(x) ((x)&(-x)) typedef long long LL; typedef pair<int,int> pii; const int maxn = 1e5+5; vector<int> factor[maxn]; double dp[maxn]; void get_factor() { for(int i = 1; i < maxn; ++i) { for(int j = i; j < maxn; j += i) factor[j].push_back(i); } } void prework() { for(int i = 2; i < maxn; ++i) { int siz = factor[i].size(); for(int j = 0; j < siz-1; ++j) { dp[i] += 1.0/siz * dp[factor[i][j]]; } dp[i]++; dp[i] *= (double)siz/(siz-1); } } void run

Make The Fence Great Again CodeForces - 1221D(dp|类比01背包)

我的未来我决定 提交于 2020-02-17 06:21:41
题意:题目要求对n个数中的某些进行任意多次的+1操作,使得对于每个元素(除开第一个)有a[i-1]!=a[i],1<i<=n,由于每个a[i]对应一个b[i],没增加1,那么费用就相应增加1*b[i],问使得在修改为满足条件a[i-1]!=a[i]的情况下最小的费用; 这个题我也是看了题解才明白的,由于每次增加1,所以最多一个元素可以增加2次1就能保证左相邻是不想等的了; 比如一个序列:1,1,1;那么我增加第二个1一次即可,如果是2,1,1,3,3;那么增加第一个1两次才行,所以这点就很重要了,一个元素只能增加0/1/2次;所以我需要把所有的情况全部枚举出来,这我感觉就是dp的思路了,就像01背包一样的感觉;01背包是对于这个物品我想么选,要么不选,所以需要枚举所有情况;而这道题是当前元素增加0次,1次或者2次,都是多种情况;注意题目中1e18,所以我需要设置无穷大为1e18多一点;对于dp那么我就需要枚举三种情况;具体一点就是:对于第一个篱笆,他有0,1,2三种情况,那么对应的第二个篱笆也是0,1,2三种情况,所以我需要两个for来枚举,由于一共有n的篱笆,所以我外面还需要一个for,并且在a[i-1]+j!=a[i]+k的情况下才能计算; 所以dp定义为dp[i][k]当修到第i个篱笆的时候增加k次的最小费用; # include <bits/stdc++.h> using

CF1205E Expected Value Again

拥有回忆 提交于 2020-02-11 09:31:41
题意 题意翻译 对于一个字符串 \(s\) ,我们定义其 美丽值 \(f(s)\) 为满足下列两个条件的正整数 \(i\) 的个数: \(1\leq i<|s|\) \(s\) 长度为 \(i\) 的前缀与后缀相等,即 \(\forall j\in N,1\leq j\leq i\) ,均有 \(s_j=s_{|s|-i+j}\) 给定正整数 \(n(1\leq n\leq 10^5),k(1\leq k\leq 10^9)\) 。设字符集大小为 \(k\) ,请求出所有长度为 \(n\) 的字符串 \(s\) 的 \(f(s)^2\) 的期望值。 做法 长度为 \(x\) 的 \(border\) 等价于 \(n-x\) 非严格周期 另 \(g_i(s)\) 为字符串 \(s\) 有周期 \(i\) 的概率, \(f(s)^2=\sum\limits_{i=1}^{n-1}E(g_{i,j}(s))\) , \(g_{i,j}(s)\) 表示字符串 \(s\) 同时具有 \(i\) 与 \(j\) 周期的概率 结论1 :有计算概率公式: \[g_{i,j}(s)=\dfrac{k^{max(i+j-n,(i,j))}}{k^n}\] Periodicity Lemma 然后开始推式子,下面关于 即 ,省略了一些没必要的东西,就是那种不会影响计算的东西 即计算 \(\sum

Codeforces - Team Rocket Rises Again

你说的曾经没有我的故事 提交于 2020-02-07 19:43:08
题目链接: Codeforces - Team Rocket Rises Again 很明显如果我们先跑一个最短路出来,我们把最短路上面的边单独拿出来建图。 然后就可以得到边全是最短路上面的边的新图。 根据题目定义我们可以发现,这个是支配树。 跑一次支配树取max即可。 AC代码: # pragma GCC optimize("-Ofast","-funroll-all-loops") # include <bits/stdc++.h> //#define int long long using namespace std ; typedef long long LL ; const LL inf = 0x3f3f3f3f3f3f3f3f ; const int N = 8e5 + 10 , M = N << 1 ; int n , m , s , vis [ N ] , mx ; LL d [ N ] ; int head [ N ] , nex [ M ] , w [ M ] , to [ M ] , tot ; inline void ade ( int a , int b , int c ) { to [ ++ tot ] = b ; nex [ tot ] = head [ a ] ; w [ tot ] = c ; head [ a ] = tot ; } inline

【递推】Fibonacci Again

别等时光非礼了梦想. 提交于 2020-01-24 12:59:40
描述 There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2). 输入 Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000). 输出 Print the word “yes” if 3 divide evenly into F(n). Print the word “no” if not. 样例输入 0 1 2 3 4 5 样例输出 no no yes no no no 题目来源 HDOJ 分析:斐波那契递推。 代码: #include<bits/stdc++.h> using namespace std; int f[1000001]; void Fibo() { f[0]=7;f[1]=11; for (int i=2;i<1000001;i++) f[i]=(f[i-1]+f[i-2])%3; } int main() { Fibo(); int n; while(cin>>n) { if (f[n]%3==0) cout<<“yes”<<endl; else cout<<“no”<<endl; } return 0; } 来源:

jquery之元素选择,查找,过滤

萝らか妹 提交于 2020-01-16 09:47:56
一、jquery操作符号:jquery(),简写为$(); 二、基本查找: 1、根据给定的ID匹配一个元素。如果选择器中包含特殊字符,可以用两个斜杠转义 例如:html码:<div id="myDiv">hello world</div> jquery码:$("#myDiv"); 结果:[ <div id="myDiv">id="myDiv"</div> ] 注意: 查找含有特殊字符的元素 html码:<span id="foo:bar"></span> <span id="foo[bar]"></span> <span id="foo.bar"></span> jquery码:#foo\\:bar #foo\\[bar\\] #foo\\.bar 2、根据给定的 class 类匹配元素。html码:<div class="myClass">div class="myClass"</div> jquery码: $(".myClass"); 结果: [ <div class="myClass">div class="myClass"</div>] 3、根据给定的元素名匹配所有元素:html码:<div>DIV1</div><div>DIV2</div> jquery码:$("div"); 结 果: [ <div>DIV1</div>, <div>DIV2</div> ] 4

HDU 1021 Fibonacci Again

会有一股神秘感。 提交于 2020-01-16 08:01:25
题目描述 There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2). Input Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000). Output Print the word “yes” if 3 divide evenly into F(n). Print the word “no” if not. Sample Input 0 1 2 3 4 5 Sample Output no no yes no no no 解题思路 一开始做这道题时,直接用的笨办法,没有去找规律,后来才知道这道题是有规律的,其实只要满足n除以4余2这个条件,就是yes,否则,就是no。 AC代码 # include <bits/stdc++.h> using namespace std ; int main ( ) { int n ; while ( cin >> n ) { if ( n % 4 == 2 ) { cout << "yes" << endl ; } else { cout << "no" << endl ; } } return 0 ;