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


and
You are supposed to calculate the value of the function 2.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 题目大意 让你维护一个堆.支持一下操作: 在某个点的下面加上另一个点,然后进行上浮操作. 询问某一点的权值. 思考历程 ...
随机推荐
- html(),val(),text()的区别
.html(),.text(),.val() 三种方法都是用来读取选定元素的内容: .html()是用来读取元素的HTML内容(包括其Html标签): .text()用来读取元素的纯文本内 容,包括其 ...
- oracle限制一个用户空闲时间
alter system set resource_limit = true; create profile idletime limit idle_time 3; alter user outln ...
- OpenJudge_1936:All in All
描述 You have devised a new encryption technique which encodes a message by inserting between its char ...
- HDU-1029_Ignatius and the Princess IV
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K (Jav ...
- 从零学React Native之02状态机
本篇文章首发于简书 欢迎关注 之前我们介绍了RN相关的知识: 是时候了解React Native了 从零学React Native之01创建第一个程序 本篇文章主要介绍下下面的知识: 1.简单界面的搭 ...
- oracle函数 REPLACE(c1,c2[,c3])
[功能]将字符表达式值中,部分相同字符串,替换成新的字符串 [参数] c1 希望被替换的字符或变量 c2 被替换的字符串 c3 要替换的字符串,默认为空(即删除之意,不是空格) [返回]字 ...
- @loj - 6354@「CodePlus 2018 4 月赛」最短路
目录 @description@ @solution@ @accepted code@ @details@ @description@ 企鹅国中有 N 座城市,编号从 1 到 N . 对于任意的两座城 ...
- 最适合 Python 入门的资源有哪些?
https://blog.csdn.net/zV3e189oS5c0tSknrBCL/article/details/81230593 学习任何一门编程语言或者技能基本上都遵循3个步骤,第一步是看,第 ...
- oracle避免在索引列上使用IS NULL和IS NOT NULL
避免在索引中使用任何可以为空的列,ORACLE将无法使用该索引 .对于单列索引,如果列包含空值,索引中将不存在此记录. 对于复合索引,如果每个列都为空,索引中同样不存在此记录. 如果至少有一个列不为空 ...
- js获取dom节点
var s= document.getElementById("test");del_ff(s); //清理空格var chils= s.childNodes; //得到s的全部子 ...