2019.12.15 QLU and SNDU期末联赛
题目列表:
1582.柳予欣的舔狗行为
1587.柳予欣的女朋友们在分享水果
1585.柳予欣和她女朋友的购物计划
1579.FFFFFunctions
1588.Zeckendorf
1586.柳予欣不想挂科
1583.Interstellar
1582.柳予欣的舔狗行为
题目链接:http://www.acmicpc.sdnu.edu.cn/problem/show/1582
Description:
某一天柳予欣想去舔爱慕已久却得不到的小姐姐(f译萱)。第一天他去给她偷偷发了一条信息,第二和第三天每天发两条信息,第四到第六天每天发三条信息。。以此类推。可惜小姐姐早就把他给屏蔽了。请问到第K天位置柳予欣一共发了多少条信息?
Input:
输入为一个数字n(1<=n<=1e5)
Output:
输出柳予欣发的信息条数。
Sample Input
1000
Sample Output
29820
思路:
暴力。
AC代码:
#include <iostream> typedef long long ll; const int maxn=1e5+10; ll a[maxn]; using namespace std; ll n,t,ans; int main(){ cin>>n; for (int i=1; i<=maxn; i++) { for (int j=0; j<i; j++) { ans+=i; t++; if (t>=n) { cout<<ans<<endl; return 0; } } } }
1587.柳予欣的女朋友们在分享水果
题目链接: http://www.acmicpc.sdnu.edu.cn/problem/show/1587
Description
Input
Only one line contains one integer ww (1\leq w\leq 100)(1≤w≤100),units are kilograms.
Output
Sample Input
8
Sample Output
YES
思路:
注意下n==2的情况就可以啦
AC代码:
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; typedef long long ll; int main(){ int n; cin>>n; if (n%2==0) { if (n==2) cout<<"NO"<<endl; else cout<<"YES"<<endl; } else cout<<"NO"<<endl; }
1585.柳予欣和她女朋友的购物计划
题目链接:http://www.acmicpc.sdnu.edu.cn/problem/show/1585
Description
Input
输入数据仅一行,包含两个正整数,它们之间用一个空格隔开,分别表示a,b的面值。(a和b均大于1,且均小于1,000,000,000)
Output
Sample Input
3 7
Sample Output
11
AC代码:
#include <iostream> using namespace std; typedef long long ll; int main(){ ll a,b; cin>>a>>b; cout<<(ll)a*b-a-b<<endl; }
1579.FFFFFunctions
题目链接:http://www.acmicpc.sdnu.edu.cn/problem/show/1579
Description




Input
Output
Sample Input
2 3 5 2 1
Sample Output
1
思路:
递归求解。
AC代码:
#include <iostream> #include <cstdio> #include <cmath> using namespace std; typedef long long ll; const int maxn=1e6+10; int a[maxn],p[maxn]; int n; inline int fun(int a,int b){ if (b==0) return a; else if(b==1||a==1) return 1; else return fun(b, a%b); } // 函数1 这里要注意是a%b。函数的功能就是求a、b的最大公约数,显然a%b 要比a-b优越很多 inline int solve(int ans,int x){ //递归求解 ans是每次的返回的结果 if (x>n) return ans; //如果x>n 说明已经调用到了x层 这样直接返回---其值就是最终结果 else return solve(fun(ans,a[p[x]]),x+1);// 每次一都向外扩展一层 } int main(){ while (scanf("%d",&n)!=EOF) { if (n==0) continue; for (int i=1; i<=n; i++) scanf("%d",&a[i]); for (int i=1; i<=n; i++) scanf("%d",&p[i]); printf("%d\n",solve(fun(a[p[1]],a[p[2]]),3));//第一次调用 是最小范围的调用(就是最里层的) } }
1588.Zeckendorf
Description
Input
Output
Sample Input
114514 0 1
Sample Output
75025 28657 6765 2584 987 377 89 21 8 1 1
思路:
首先要知道斐波那契数列是什么 ,如 1,1,2,3,5........;
就是从第三项开始,每一项都等于前两项的和。 因为题目要求不能从重复中取,
这样数列就是 1,2,3,5........ 一直到6e18(这样才能保证数据不会越界,爆掉longlong);
还有一点就是任何一个自然数都能被斐波那契数列表示~当时做的时候并不知道~
「ps:至于为什么第一个小于n的斐波那契数一定是组成的那个呢?
我们来证一下:已知:任何一个自然数都能被斐波那契数列表示
所以 n减去任何一个斐波那契数后 依然能够被 斐波那契数列 表示
因此在题目要求斐波那契数个数最少的条件下,我们要用贪心思想。
即减去第一个小于n的斐波那契数 」
『对于本题而言:因为每个斐波那契数只能用一次 所以只有减去第一个小于n的斐波那契数 才可以既能达到最优解 ,又不破坏剩下的斐波那契数列~』
AC代码:
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> typedef long long ll; const ll maxn=6e18; using namespace std; ll a[1000],n; int t; int main() { a[1]=1;a[2]=2; for (int i=3;; i++) { a[i]=a[i-1]+a[i-2]; if (a[i]>maxn) { t=i-1; break; } }// 找出斐波那契数列 个数为t个 while (~scanf("%lld",&n)) { if (!n) continue; else { for (int i=t; i>0; i--) { //从后向前找 if (n>=a[i]) { //n在不小于0的情况下能减去就减去。 n-=a[i]; if (n) printf("%lld ",a[i]); else { printf("%lld\n",a[i]); //注意格式问题 break; } } } } } }
1586.柳予欣不想挂科
Description
Input
Output
Sample Input
5 2 3 4 1 2
Sample Output
5
Hint
对于样例来说,最少需要五次,每次补习科目区间为:
[1,5] [1,3] [2,3] [3,3] [5,5]
即可使所有科目的成绩提高到目标成绩了
思路:
AC代码:
#include <iostream> const int maxn=1e5+10; typedef long long ll; using namespace std; int n; int a[maxn]; ll ans; int main(){ cin>>n; for (int i=1; i<=n; i++) cin>>a[i]; ans=a[1]; for (int i=2; i<=n;i++) if (a[i]>a[i-1]) ans+=a[i]-a[i-1]; cout<<ans<<endl; }
1583.Interstellar
Description
Input
Output
Sample Input
3 2 3 3 2 1 4
Sample Output
7 4 5
思路:
题意就是让你找 n(n<=5)维空间能被m个 他的超平面切割为多少个不同的部分,同时读题了解到n维空间的超平面就是 n-1维的。
拿三维空间为例:它的超平面就是二维的,即我们常识中的平面;同样平面的超平面就是直线。
这道题的思路就是递推,找到他们之间的关系就可以啦。
AC代码:
#include <iostream> #include <cstdio> typedef long long ll; using namespace std; ll a[6][16010];//储存每一种答案,预处理。 ll x,y,t; int main(){ for(int i=0;i<=5;i++) a[i][0]=1; for(int j=0;j<=16000;j++) a[0][j]=1;//初始化,每一个维度空间至少都是1部分 for(int i=1;i<=5;i++) for(int j=1;j<=16000;j++) //i维空间被j个超平面切割 a[i][j]=a[i][j-1]+a[i-1][j-1];//等价于 i维空间被(j-1)个超平面切割 与 (i-1)维空间被(j-1)个超平面切割的和。 cin>>t; while (t--) { cin>>x>>y; cout<<a[x][y]<<endl; } }
2019.12.15 QLU and SNDU期末联赛的更多相关文章
- 第十八次CSP认证游记 | 2019.12.15
CSP认证的考试是Haogod介绍的,取得一定成绩之后能有机会参加CCSP的分赛区和全国决赛.这次来参加认证要感谢老师的奔走为我们申请学校的报销,虽然最终因为这不是比赛所以报名费和差旅费下不来,但是老 ...
- NOI2019退役记 upd:2019.12.1
(我把原来写的东西全部删掉了) AFO. 我退役了,\(\mbox{yyb}\)退役了. 至少,在接下来的日子里,我得投身到文化课,度过快乐的高三生活了. 这两年的\(OI\)生涯给了我很多,让我学会 ...
- Tencent Cloud Developers Conference(2018.12.15)
时间:2018.12.15地点:北京朝阳悠唐皇冠假日酒店
- Data truncation: Incorrect datetime value: 'May 15, 2019 4:15:37 PM
因为系统在windows下测试过是正常的 windows下的jdk+ windows下安装的mysql 全部cases通过 linux下的jdk + windows下安装的mysql 新增和更新,影响 ...
- MyBatis 配置/注解 SQL CRUD 经典解决方案(2019.08.15持续更新)
本文旨在记录使用各位大神的经典解决方案. 2019.08.14 更新 Mybatis saveOrUpdate SelectKey非主键的使用 MyBatis实现SaveOrUpdate mybati ...
- IDEA下将dubbo简单项目跑Demo(2019.12版)
项目架构(聚合项目,父子模块) src没用,所以删去 选择maven项目,不用勾选模板骨架,直接main方法,因为不用到服务器 顺序是按照:添加pom依赖-接口实现类-配置文件 项目环境 IDE:In ...
- 2021.12.15 P2328 [SCOI2005]超级格雷码(找规律填空)
2021.12.15 P2328 [SCOI2005]超级格雷码(找规律填空) https://www.luogu.com.cn/problem/P2328 题意: 输出n位B进制的格雷码. 分析: ...
- OI生涯回忆录 2018.11.12~2019.4.15
上一篇:OI生涯回忆录 2017.9.10~2018.11.11 一次逆风而行的成功,是什么都无法代替的 ………… 历经艰难 我还在走着 一 NOIP之后,全机房开始了省选知识的自学. 动态DP,LC ...
- [JZOJ5977] 【清华2019冬令营模拟12.15】堆
题目 其中n,q≤500000n,q\leq 500000n,q≤500000 题目大意 让你维护一个堆.支持一下操作: 在某个点的下面加上另一个点,然后进行上浮操作. 询问某一点的权值. 思考历程 ...
随机推荐
- python的解释器类型
Python解释器 当我们编写Python代码时,我们得到的是一个包含Python代码的以.py为扩展名的文本文件.要运行代码,就需要Python解释器去执行.py文件. 由于整个Python语言从规 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十章:阴影贴图
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十章:阴影贴图 本章介绍一种在游戏和应用中,模拟动态阴影的基本阴影 ...
- 【水滴石穿】react-native-template-app
这个也是一个基础项目 地址如下https://github.com/ndlonghi/react-native-template-app 点击登陆跳转到首页 分析代码如 react-native-te ...
- dsadsa
1.Swift预览 一般来说,编程语言教程中的第一个程序是在屏幕上打印“Hello, world”.在 Swift 中,可以用一行代码实现: println("Hello, world&qu ...
- 【Mysql的那些事】数据库之ORM操作
1:ORM的基础操作(必会) <1> all(): 查询所有结果 <2> filter(**kwargs): 它包含了与所给筛选条件相匹配的对象 <3> get(* ...
- hdu1527 威佐夫博奕
有2堆石子,有2个人,每个人可以从一堆取或从2堆取一样的个数的石子,至少取1个.问先手的是胜或输.设(ak,bk)我么成为局势. (0,0)(1,2)(3,5)(4,7)..这种先手必输的叫奇异局势. ...
- MySQL命令行分号无法结束问题解决
背景:输入一串查询语句,以分号结束,发现没有结束,再打回车,分号,还是不完.什么exit,quit,bye,都不顶用如果要ctrl+C吧,又得退出mysql,一切重来,很麻烦.后来终于发现,引起这种现 ...
- wepy ——$apply
1.说明 在异步函数中更新数据的时候,必须手动调用 $apply 方法. 2.代码和效果 // html <button type="primary" plain=" ...
- @atcoder - AGC034E@ Complete Compress
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个 N 个点的树,编号为 1, 2, ..., N.第 i ...
- ping的使用
ping -t cnblogs.com 可以一直ping网址显示对应的响应时间