呃。自闭了自闭了。我才不会说我写D写到昏天黑地呢。


I  Characters with Hash

题目链接:https://nanti.jisuanke.com/t/31461

题意:给你一个字符串s,一个种子字母L。根据 |int(L) - s[i]|公式的到hash后的字符,如果是个位数就变成两位数,最后去掉前导0计算字符串长度。也就是0->00 7->07.最后统计如果前面有0就都去掉。如果在中间qwq就不用啦。

题解:暴力模拟//先开始卡题意。。初始长度就设成2n好了。如果判断前面有0就-=2,如果是个位数的话-=1,后面都是长度为2啦。其实也就是判断一下最前面的字符即可。

虽然这题水,但是我真的卡题意了。都不好意思说自己过了六级。, 有个坑。。长度为0的时候输出1。

代码:

 #include <iostream>
#include <cstdio>
#include <string>
using namespace std; string s; int main(){
int T;
scanf("%d", &T);
while(T --){
int n;
char seed;
cin>>n>>seed;
cin>>s;
int ans = * n;
//只需要判断第一个是不是为0还是个位数
for(int i = ; i < n ;i++){
int tmp = abs(seed-s[i]);
if(tmp == ){
ans -= ;
}
else if(tmp < ){
ans -= ;
break;
}
else{
break;
}
}
if(ans == )
ans = ;
cout<<ans<<endl;
}
return ;
}

H  Ryuji doesn't want to study

题目链接:https://nanti.jisuanke.com/t/31460

题意:两个操作,1、l,r 查询a[l]*Len + a[l+1]*(Len-1) … + a[r]的和。

        2、b c,把a[b]->c

题解:树状数组维护一下a[i] * (r-i+1)的和,以及维护一下a[i]。。(学长的代码。!!超棒)

代码:

 #include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long ll a[], b[], c[]; ll lowbit(ll x){
return x&(-x);
} int n;
ll sum(ll x){
ll s = ;
while(x > ){
s += c[x];
x -= lowbit(x);
}
return s;
} void add(int x, ll val){
while(x <= n){
c[x] += val;
x += lowbit(x);
}
} ll sum1(ll x){
ll s = ;
while(x > ){
s += b[x];
x -= lowbit(x);
}
return s;
} void add1(int x,ll val){
while( x <= n){
b[x] += val;
x += lowbit(x);
}
} int main(){
int q;
scanf("%d%d", &n, &q);
for(int i = ;i <= n; i++){
scanf("%lld", &a[i]);
add(i, a[i] * (n - i + ));
add1(i, a[i]);
}
for(int i = ; i <= q; i++){
int l, r, op;
scanf("%d", &op);
if(op == ){
scanf("%d%d", &l, &r);
printf("%lld\n", sum(r) - sum(l-) - (sum1(r) - sum1(l-)) * (n - r));
} else {
scanf("%d%d", &l, &r);
add(l, (r - a[l]) * (n - l + ));
add1(l, r - a[l]);
a[l] = r;
}
}
return ;
}

G  Trace

题目链接https://nanti.jisuanke.com/t/31459

题意:有一波一波的海浪,每一波海浪都会覆盖上一波的部分痕迹。求海浪打完后所留下的痕迹长度。海浪是个矩形,左下角0,0,右上角题目输入的x,y。

题解:这个题很毒。TLE了好多发。队友后面直接崩溃了。QAQ。用两个set维护。倒着求,找到当前比输入的x,y第一个小的sx,sy。ans += abs(x-sx),ans+= abs(y-sy)。大概这个意思。赛后在群里看到代码了才恍然大悟。emmm..还有就是对set不太熟悉。哎。

代码:

 #include <iostream>
#include <cstdio>
#include <string>
#include <set>
using namespace std;
#define ll long long
const int maxn = 1e5+;
int n,m;
int x[maxn],y[maxn];
set<int> xx;
set<int> yy;
set<int>::iterator it;
ll ans = ;
void addl(int sx,int sy){
it = xx.lower_bound(sx);
if(it == xx.begin())
ans += sx;
else {
it--;
ans += sx - *it;
}
it = yy.lower_bound(sy);
if(it == yy.begin())
ans += sy;
else{
it--;
ans += sy - *it;
}
}
int main(){
cin>>n;
for(int i=; i<n; i++)
cin>>x[i]>>y[i];
for(int i = n-; i >= ; i--){
addl(x[i],y[i]);
xx.insert(x[i]);
yy.insert(y[i]);
}
cout<<ans<<endl;
return ;
}

接着更新哎。


D Easy Math

题目链接https://nanti.jisuanke.com/t/31456

题意:计算$ ∑^{m}_{i = 1}$ µ (i*n)

题解:呃。真的不是很想面对这题。当时推出来直接上杜教筛,就被打爆了。对不起队友。

正经题解:

  设f(m,n) = $ ∑^{m}_{i = 1}$ µ (i*n)

    f(m,n)  = $∑^{m}_{i = 1}$ µ(i)*µ(n) * [gcd(i,n) == 1]

      = $∑^{m}_{i = 1}$ µ(i)*µ(n) * $∑_{ d|(i,n)}$µ(d)

      = $\mu(n)\sum\limits_{d|n} \mu(d) \sum\limits^{\lfloor m/d \rfloor}_{i = 1} \mu(i*d)$

      = $\mu(n)\sum\limits_{d|n} \mu(d) f(\lfloor (m/d) \rfloor,d)$

    

  几种终止情况
  m = 0,f(m,n) = 0

  m = 1,f(m,n) = µ(n)

  n = 1,f(m,n)  =$\sum\limits^{m}_{i = 1} \mu(i)$ ->杜教筛

代码:

 #include <cstdio>
#include <map>
#include <iostream>
#include <map>
using namespace std;
#define ll long long
const int N = 5e6; ll n,m; int mu[N+],pri[N+],top;
bool mark[N+];
map<ll,ll>V; int cnt;
ll p[N];
ll val[N];
int bit[N]; /*杜教筛*/
void init(){
mu[]=;
for(int i = ; i <= N; i++){
if(!mark[i]){
pri[++top] = i;
mu[i] = -;
}
for(int j = ; j <= top && i * pri[j] <= N; j++){
mark[ i * pri[j] ] = true;
if(i % pri[j] == )
break;
mu[ i * pri[j] ] = -mu[i];
}
}
for(int i = ; i <= N; i++)
mu[i] += mu[i-];
}
ll calc(ll x){
if(x <= N)
return mu[x];
if(V[x])
return V[x];
ll ans = ;
for(ll i = ,r; i <= x; i = r+){
r = x/(x/i);
ans -= calc(x/i) * (r-i+);
} V[x] = ans;
return ans;
} ll phi(ll x){
return ( (bit[x] & ) ? - : );
} ll solve(ll m, ll n) {
if (bit[n] == )
return calc(m);
if (m == )
return ;
if (m == )
phi(n);
ll ans = ;
for (ll i = n; ; i = (i-) & n){
ans += phi(i) * solve( m/val[i] , i);
if (!i)
break;
}
return ans * phi(n);
} int main(){
init();
cin>>m>>n;
ll x = n;
cnt = ;
int flag = ;
for( ll i = ; i * i <= x ;i++){
if(x%i == ){
//判断有偶数个因子
int t = (x/i) % i;
if(t == ){
flag = ;
break;
}
//不是的话加入
p[cnt++] = i;
while(x % i == ){
x /= i;
}
}
}
if(flag){
cout<<<<endl;
return ;
}
if(x > )
p[cnt++] = x;
for(int i = ; i < (<<cnt); i++){
bit[i] = ;
val[i] = ;
for(int j = ; j < cnt; j++){
if(i & (<<j) ){
bit[i]++;
val[i] *= p[j];
}
}
}
cout<<solve(m,(<<cnt)-)<<endl;
return ;
}

【2018ACM/ICPC网络赛】徐州赛区的更多相关文章

  1. 【2018ACM/ICPC网络赛】沈阳赛区

    这次网络赛没有打.生病了去医院了..尴尬.晚上回来才看了题补简单题. K  Supreme Number 题目链接:https://nanti.jisuanke.com/t/31452 题意:输入一个 ...

  2. 【2018ACM/ICPC网络赛】焦作赛区

    A Magic Mirror 题目链接:https://nanti.jisuanke.com/t/31710 题意:输入字符串,如果是“Jessy”就输出“Good Guy!",否则输出“D ...

  3. 【icpc网络赛大连赛区】Sparse Graph

    Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submissi ...

  4. Ryuji doesn't want to study 2018徐州icpc网络赛 树状数组

    Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, ea ...

  5. Trace 2018徐州icpc网络赛 (二分)(树状数组)

    Trace There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx ...

  6. Trace 2018徐州icpc网络赛 思维+二分

    There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy) ...

  7. Features Track 2018徐州icpc网络赛 思维

    Morgana is learning computer vision, and he likes cats, too. One day he wants to find the cat moveme ...

  8. 2019 徐州icpc网络赛 E. XKC's basketball team

    题库链接: https://nanti.jisuanke.com/t/41387 题目大意 给定n个数,与一个数m,求ai右边最后一个至少比ai大m的数与这个数之间有多少个数 思路 对于每一个数,利用 ...

  9. Supreme Number 2018沈阳icpc网络赛 找规律

    A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying ...

随机推荐

  1. CSS:CSS 组合选择符

    ylbtech-CSS:CSS 组合选择符 1.返回顶部 1. CSS 组合选择符 CSS 组合选择符 组合选择符说明了两个选择器直接的关系. CSS组合选择符包括各种简单选择符的组合方式. 在 CS ...

  2. docker swarm集群挂载宿主机目录

    创建DOCKER集群,挂载宿主机目录src:宿主机目录,dst:容器目录 docker service create --name testrd --detach=false --mount type ...

  3. eclipse spring boot 项目出现java.lang.ClassCastException 解决方法

    问题 eclipse spring boot 项目出现java.lang.ClassCastException 解决方法: 重新生成项目

  4. C#中的this关键字

    C# this关键字的四种用法 - 天碼行空 - 博客园 https://www.cnblogs.com/jh007/p/6120654.html C#中this关键字详解 - lin37985的专栏 ...

  5. ICPC Asia Nanning 2017 F. The Chosen One (高精度运算)

    题目链接:The Chosen One 比赛链接:ICPC Asia Nanning 2017 题意 \(t\) 组样例,每组给出一个整数 \(n(2\le n\le 10^{50})\),求不大于 ...

  6. FreeBSD_11-系统管理——{Part_9-SVN}

    一.使用 svn / svnlite 代替 freebsd-update 及 portsnap 等常规工具更新系统及 ports 源码 二.安装可信 ca 机构列表 cd /usr/ports/sec ...

  7. Jenkins和Docker

    由于采用了Docker版的Jenkins,导致在Jenkins里无法调用Docker命令行工具进行Docker镜像构建 有三种解决方案: 1. 安装Docker插件,利用Jenkins插件进行构建 2 ...

  8. hdu6354 /// 线段树

    题目大意: 给定n m x y z 长度为n的序列初始为0 接下来m个操作 l r v 将l r区间内比v小的数都变成v l r v由x y z和给定的函数生成 线段树维护区间 最大值 最小值 再加 ...

  9. Java 获取当前系统的操作系统类型

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/fangchao2011/article/d ...

  10. 继续搞我的linux

    小程序研发已经告一段落,还是继续我的Linux研究.上次因为捣鼓那个fastab,结果吧虚拟机搞崩溃了.好吧,这次老子来装正式机,从机房拉来了一台破烂货,联想的老式服务器,开工吧. 用UltraISO ...