[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 写个记忆化搜索. 接近O(n)的复杂度吧 [代码] #include <bits/stdc++.h> using namespace std; const int N = 1e6; int g[N+10]; int pre[N+10][20]; int f(int x){ int temp = 1; while (x){ if (x%10!=0) temp*=(x%10); x/=10; } return temp; } in
D. Tree 最暴力的想法自然是,对于每一次询问,沿着父亲一点一点往上跳模拟.这样似乎并不能优化... 稍微好一点的想法是对于每一个点开一个nxt数组表示父亲中权值大于他的里面离他最近的在哪里,同样对于每一次询问模拟往上跳,每次加点模拟往上找,复杂度依旧没有变化,但为我们提供了一个思路,我们可以倍增啊! 首先我们对于2操作,我们记录sum[x][i]表示他的2^i个nxt的值的和是多少,这样我们就可以快速求出在总权值小于x的前提下最多能跳到哪里. 考虑如何求出这个数组. 定义nxt[x][i]
Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim. The killer starts with two potentia
Moriarty has trapped n people in n distinct rooms in a hotel. Some rooms are locked, others are unlocked. But, there is a condition that the people in the hotel can only escape when all the doors are unlocked at the same time. There are m switches. E
Molly Hooper has n different kinds of chemicals arranged in a line. Each of the chemicals has an affection value, The i-th of them has affection value ai. Molly wants Sherlock to fall in love with her. She intends to do this by mixing a contiguous se
前四题比较水,E我看出是欧拉函数傻逼题,但我傻逼不会,百度了下开始学,最后在加时的时候A掉了 AC:ABCDE Rank:182 Rating:2193+34->2227 终于橙了,不知道能待几天 A.A Serial Killer 题目大意:一开始给你两个字符串,每次给你当前两个串中的一个和一个新的串,用新的串换掉旧的,每次输出当前的串.(次数<=1000) 思路:二逼题 #include<iostream> using namespace std; int main() { s