呃。自闭了自闭了。我才不会说我写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. cut 从/a/b/c/d/e获取/a/b/c

    https://www.cnblogs.com/chenxiaomeng/p/10066821.html two_dir=`echo /a/b/c/d/e/f | cut -d"/" ...

  2. certbot免费证书

    yum install python-certbot-nginx 开启防火墙443端口 firewall-cmd --add-port=443/tcp --permanent 别忘了重启 firewa ...

  3. web APP 开发之踩坑手记

    屏蔽输入框怪异的内阴影 -webkit-appearance:none 禁止自动识别电话和邮箱 <meta content="telephone=no" name=" ...

  4. css 画饼图 倒计时圆圈

    html <div class="pie"></div> css .pie{ width: 200px; height: 200px; border-rad ...

  5. js的基本语法规范

    1.不要在同一行声明多个变量: 2.使用===/!==来比较true/false的返回值: 3.使用字面量替代new Array这种形式: 4.不要使用全局函数: 5.switch语句必须带有defa ...

  6. 使用wireshark在windows平台下捕获HTTP协议数据包中的帐号密码信息

    1.打开wireshark软件,从Interface List中选择相应的网卡,例如我的PC机上是“本地连接”,然后选择”Start”启动抓包程序. 2.打开学校主页,输入账号和密码登录校内邮箱. 3 ...

  7. eclipse 在复制/粘贴 时很卡(转)

    最近发现eclipse在按Ctrl+C 时卡的要命,在网上找了一下,发现原来如此: 打开选项: Window -> Preferences -> General -> Editors ...

  8. Linux fork创建子进程

    1.  pid_t fork(void); 功能:创建父子进程 参数:无 返回值:成功:在父进程中:返回值为子进程的PID 在子进程中:返回值为0 失败:-1 注意: 1)fork函数是用来创建进程的 ...

  9. Sublime Text3中MarkDown的使用

    前言 当我们想要在Sublime文本编辑器中编辑markdown时,需要先安装markdown插件,因为Sublime里默认没有安装该插件,同时在编辑markdown文本时可以实时预览编辑效果. 具体 ...

  10. java中的访问修饰符详解

    主要讲述一下java中protected的修饰控制范围. 在叙述protected修饰符使用之前,先来说一下java,可以发现,开发java程序是一个时时刻刻都在编写类.开发类.定义类的过程.类里面可 ...