呃。自闭了自闭了。我才不会说我写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. php开发面试题---Mysql常用命令行大全

    php开发面试题---Mysql常用命令行大全 一.总结 一句话总结: 常见关键词:create,use,drop,insert,update,select,where ,from.inner joi ...

  2. CSS:CSS Positioning(定位)

    ylbtech-CSS:CSS Positioning(定位) 1.返回顶部 1. CSS Positioning(定位) position 属性指定了元素的定位类型. position 属性的四个值 ...

  3. P2216 [HAOI2007]理想的正方形 (单调队列)

    题目链接:P2216 [HAOI2007]理想的正方形 题目描述 有一个 \(a\times b\)的整数组成的矩阵,现请你从中找出一个 \(n\times n\)的正方形区域,使得该区域所有数中的最 ...

  4. PostgreSQL——服务器配置_{postgresql.conf}

    一.设置参数 所有参数名称都是不区分大小写的 值为字符串时,需要单引号 值为数值时不需要单引号,但带单位时,需要单引号 配置文件(如:postgresql.conf.postgresql.auto.c ...

  5. LCA的 Trajan 算法

    参考博客 参考博客 根据博客的模拟,就可以知道做法和思想. 现在就是实现他. 例题 :hdu  2586  题意:m 个询问,x  到  y  的距离,我们的思想就是求出:x到根的距离+y到根的距离- ...

  6. 伪类checked

    困惑了好久的复选框自定义样式终于有了谜底,原来就是一个 :checked 伪类 他的意思就是 匹配任意被勾选/选中的radio(单选按钮),chexked(复选框),或者option(select项) ...

  7. 2018-8-10-win10-uwp-反射

    title author date CreateTime categories win10 uwp 反射 lindexi 2018-08-10 19:17:19 +0800 2018-2-13 17: ...

  8. 面向对象oop 和类

    面向对象与面向过程的区别 面向对象:面向对象的思维模式说白了就是分类思维模式.思考问题首先会解决问题需要哪些分类,然后对这些分类进行单独思考.最后,才对某个分类下的细节进行面向过程的思索 自我理解(领 ...

  9. ArrayList 详解

    基本介绍 ArrayList: 支持null元素.有顺序.元素可以重复. 可以动态增长和缩减的索引序列,基于数组实现的List类(查询效率高,而在插入删除性能下降很多(需要移动数组元素)). 底层的数 ...

  10. 在IDEA安装SonarLint插件的步骤和使用方法

    1.安装SonarLint插件方式 2.使用方式 3.效果