山师2019停训赛补题

我真的说实话这套题感觉弄得很仓促,但是也是存在不错的题目的
目前已补:
01 03 06 07 08 09 10 11
目前未补:
02 04 05 12

1001 Zeckendorf(规律)

这个直接找规律看看就行了,也没几个斐波那契数的,我这里直接暴力求解的。实际上所有的数都可以被斐波那契数拆分然后一个一个找最大的减去就行了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
using namespace std;
long long a[1005];
int main()
{
a[1]=1,a[2]=1;
for(int i=3;i<=92;i++)
a[i]=a[i-1]+a[i-2];
long long n;
while(~scanf("%lld",&n))
{
if(n==0)
continue;
while(n)
{
int pos,f=0;
for(int i=1;i<=92;i++)
{
pos=i;
if(a[i]>=n)
{
if(a[i]>n)
f=1;
break;
}
}
if(f)
{
n-=a[pos-1];
printf("%lld%c",a[pos-1],n?' ':'\n');
}
else
{
n-=a[pos];
printf("%lld%c",a[pos],n?' ':'\n');
}
}
}
}

1002 This brave man is super strong but super cautious!(字符串模拟)

究极恶心的模拟,说也感觉说的不是多么清楚,还有人能做出来真的是太强了,我是直接恶心到了不做了,一直做不对

1003 Interstellar(数学结论+猜谜)

赛场能做出来的要么是知道结论的,要么就是老猜谜家了,这种猜谜东西我是之前不知道的。我看了看二维三维的结论发现了三维空间的要用二维空间的去推那么我们可以注意到n维空间的可以用n-1维空间的推出那么我们的公式就是

f[n]=f[n-1]+g[n-1]

f代表当前的维数n个上一维数所能弄出来的部分,g代表上一维

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>
using namespace std;
const int N=200005;
long long f[6][N];
int main()
{
for(int i=1;i<=16000;i++)
f[0][i]=1;
for(int i=0;i<=5;i++)
f[i][0]=1;
for(int i=1;i<=5;i++)
{
for(int j=1;j<=16000;j++)
f[i][j]=f[i][j-1]+f[i-1][j-1];
}
int t;
scanf("%d",&t);
while(t--)
{
long long n,m;
scanf("%lld%lld",&n,&m);
printf("%lld\n",f[n][m]);
}
}

1004 Rubik’s cube Simulator(不明)

看着一堆英文和这复杂的样例,这应该是个原题。。。但是我也不大想看了

1005 柳予欣和她的女朋友们(不明)

像是一个图论,但是我现在图论也不会多少,反正我是不会

1006 柳予欣的舔狗行为(暴力)

直接把要的东西搞出来就行了,然后直接按照询问输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <bits/stdc++.h>
using namespace std;
long long a[100005],pre[100005],p;
int main()
{
int cnt=1;
while(1)
{
if(p>100000)
break;
for(int j=1;j<=cnt;j++)
a[++p]=cnt;
cnt++;
}
memset(pre,0,sizeof(pre));
for(int i=1;i<=100001;i++)
pre[i]=pre[i-1]+a[i];
long long n;
scanf("%lld",&n);
printf("%lld",pre[n]);
}

1007 柳予欣和她女朋友的购物计划(小凯的疑惑)

1
2
3
4
5
6
7
8
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long a,b;
scanf("%lld%lld",&a,&b);
printf("%lld",a*b-a-b);
}

1008 柳予欣不想挂科(思维)

老思维题了,我这想了得快2h才交的,没想到运气好一遍过了。如果我去现场赛的话做出5题或许还能搞搞这题的一血,也不一定我比较喜欢跟榜也。
经过深思熟虑发现规律就是如果有下降后上升的数在数组里面那么他就能分出来一堆的块,我们画图可以知道这些块能额外提供一些操作,于是我们找规律就能得到一些规律。具体看代码吧

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <bits/stdc++.h>
using namespace std;
const int N=200005;
long long maxn=0,re=0,a[N],ans=0,now=0;
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%lld",&a[i]);
now=a[1];
for(int i=2;i<=n-1;i++)
{
now=max(now,a[i]);
if(a[i]<a[i-1]&&a[i]<=a[i+1])
ans+=now,ans-=a[i],now=0;
}
now=max(now,a[n]);
ans+=now;
printf("%lld",ans);
}

1009 柳予欣的女朋友们在分享水果(坑人的签到题)

注意2分解后为两个1都是奇数!!!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
if(n==2||(n&1))
printf("NO");
else
printf("YES");
}
```
# 1010 FFFFFunctions(GCD)
看过欧几里得算法的应该都能一眼看出这是什么题吧
```cpp
#include <bits/stdc++.h>
using namespace std;
int a[1000005],p[1000005];
int main()
{
int n;
while(~scanf("%d",&n))
{
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=n;i++)
scanf("%d",&p[i]);
int ans=0;
for(int i=1;i<=n;i++)
ans=__gcd(ans,a[p[i]]);
if(ans)
printf("%d\n",ans);
}
}

1011 Solved Math problem(莫比乌斯反演)

SDOI原题,还有规律,我直接糊的板子我也不会

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N =200005;
ll p[N],bk[N],mu[N],q,pre[N],now[N],mod=998244353;
void get()
{
mu[1]=1;
for(int i=2;i<=100000;i++)
{
if(!bk[i])
p[++q]=i,mu[i]=-1;
for(int j=1;j<=q&&i*p[j]<=N-5;j++)
{
bk[i*p[j]]=1;
if(i%p[j]==0)
break;
mu[i*p[j]]=-mu[i];
}
}
for(int i=1;i<=100000;i++)
pre[i]=pre[i-1]%mod+mu[i]%mod,pre[i]%=mod;
for(int i=1;i<=100000;i++)
{
ll ans=0;
for(ll l=1,r=0;l<=i;l=r+1)
{
r=i/(i/l);
ans=ans%mod+(r-l+1)%mod*(i/l)%mod,ans%=mod;
}
now[i]=ans%mod;
}
}
int main()
{
get();
ll t;
ll n,m;
while(~scanf("%lld%lld",&n,&m))
{
ll ans=0;
for(ll l=1,r=0;l<=min(n,m);l=r+1)
{
r=min(n/(n/l),m/(m/l));
ans=ans%mod+(pre[r]-pre[l-1])%mod*now[n/l]%mod*now[m/l]%mod,ans%=mod;
}
printf("%lld\n",(ans%mod+mod)%mod);
}
}

1012 柳予欣的背水一战(不明)

我题也没仔细看,我这先鸽子这个吧。似乎出题人还很热情的邀请我去做他的题,可是似乎我这题目都没大想能看懂的样子

就算是一分钱,也是对作者极大的支持
------ 本文结束 ------

版权声明

Baccano by baccano is licensed under a Creative Commons BY-NC-ND 4.0 International License.
baccano创作并维护的Baccano博客采用创作共用保留署名-非商业-禁止演绎4.0国际许可证
本文首发于baccano 博客( http://baccano.fun ),版权所有,侵权必究。

小游戏

---小游戏:要不要来选择一下自己可能的老婆?---

简易发声器

---简易的七键钢琴插件---

可以使用鼠标点击琴键也可以使用主键盘1-7或者小键盘的1-7来操作

那么现在开始吧

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
0%