呃。自闭了自闭了。我才不会说我写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. 其它课程中的python---5、Pandas处理数据和读取数据

    其它课程中的python---5.Pandas处理数据和读取数据 一.总结 一句话总结: 记常用和特例:慢慢慢慢的就熟了,不用太着急,慢慢来 库的使用都很简单:就是库的常用函数就这几个,后面用的时候学 ...

  2. pair的用法

    如何定义?(初始化) 1. pair<int,int>p; 2.定义即初始化,也可以这个样子 pair<,); 里面的类型还可以是string,double等. 3.还可以这样子初始 ...

  3. 如何使用Intellij IDEA工具导入SVN项目

    Intellij IDEA是目前主流的IDE开发工具,工程项目导入也是必不可少的操作,本文讲述如何用 IDEA工具导入SVN项目. 步骤一:选择VCS打开Intellij IDEA开发工具,在导航栏中 ...

  4. node+webpack+vue的环境搭建

      一般第一次搭建环境的时候,多多少少还是会出点状况的.这个时候多去百度,看牛人怎么解决,然后跟着尝试,多试几遍还是能解决的. 先说一下我安装的过程吧 1.我一开始按照官网的来搭建,失败了.报错内容是 ...

  5. 7-MySQL-Ubuntu-操作数据表的基本操作(二)

    修改数据表的结构 (1)向数据表中添加新的字段 alter table 表名 add 字段名 类型及约束;  (2)修改字段的属性(字段的数据类型和约束) 注:modify不能修改字段名,只能修改字段 ...

  6. react-swiper 如何实现滑动小卡片的移动?

    1.引入插件 import ReactSwipes from 'react-swipes'; import './swiperCard.css'; 2.代码构成 export default clas ...

  7. C#链接Mysql

    先在网上找到Mysql.Data.dll组件, 文件下载地址为http://dev.mysql.com/downloads/connector/net/6.6.html#downloads ,下载平台 ...

  8. RHEL5/6/7中常用命令及命令之间的差异

    System basics Task RHEL5 RHEL6 RHEL7 View subscription information /etc/sysconfig/rhn/systemid /etc/ ...

  9. eureka多实例,模拟多台机器

    本文只有一个eureka server项目,运行在不同的端口,模拟两台eureka服务.开发使用eclipse 4.8 先说pom.xml文件,如果出现问题,首先考虑springboot和其他包版本冲 ...

  10. php导出csv并保存在服务器,返回csv的文件路径

    <?php namespace app\common\controller; use think\Controller; use think\Db; class Csv extends Cont ...