题目列表:

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

The hot summer came so quickly that fyx and lmz decided to buy a big and sweet watermelon. They want to cut the watermelon in two parts, and the weight of each part is an even number.They quickly decide which melon to buy. Do you know if you want to buy this melon?

Input

Only one line contains one integer ww (1\leq w\leq 100)(1≤w≤100),units are kilograms.

Output

If it can meet the requirements, you will output "YES", otherwise output "NO".

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

一天,柳予欣和她的一个女朋友fyx去买包包。可惜的是柳予欣现在手里只有两种面值的钱a,b(a,b彼此互为素数,即这两个整数的公因数只有1),数量无限大。为了不让自己没面子,他想知道无法准确支付的物品中(就是不通过找零,用非负数个钱a与钱b不能凑成的价格中),最贵的价值是多少金币?

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

Define two functions.

Fucntion 1:

Function 2:
Now, you are given two sequences:andYou are supposed to calculate the value of the function 2.

Input

The input contains several test cases and the number of test cases is no more than 500.

For each test case, the first line contains a interger n. The second line contains n intergers for the sequence a. The third line contains n intergers for the sequence p which is a permutation for {1,2,3,...,n}.
(1<=n<=1000000, 1<=ai<=1000000000, 1<=pi<=n)
hint: while n is 0,you should output nothing and input next case

Output

For each test case, output a interger in one line for the value of the function 2.

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

给出一个正整数n,是否可以用若干个不相同的斐波那契数的和来表示给出的数?

如果可以表示,给出使用最少斐波那契数个数的表示方法,降序输出这些斐波那契数;如果不可以表示,输出-1。

Input

多组输入,每行一个正整数n(0<=n<=9e18)。应注意的是当n为0的时候为无效输入,应不进行操作继续读入下个数据。

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.柳予欣不想挂科

题目链接:http://sdnuoj.rainng.com/problem/show/1586

Description

期末考试要到了,学习不好的柳予欣要挂科了。这时他的一个女朋友lmz过来帮他补习科目。一共有n门科目,柳予欣对于每门都有目标成绩mi。lmz每次可以让他任意一个连续区间的科目的目标成绩提升一(n门科目初始状态成绩全为0)。因为柳予欣太懒,他只想把每一门补习到他想要的成绩,高了不行低了也不行。请问最少要让lmz帮他补习多少次?

 

Input

第一行一个数表示n (n <= 100000)

第二行n个数表示每个mi即每个科目的目标成绩。

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

    In the near future, with the deterioration of the earth's natural environment, human beings are facing the threat of being unable to survive. But there's still hoping: scientists found a wormhole near saturn in our solar system which connects a piece of space near a blackhole that a habitable planet is moving around it. Dr.cooper is considering to send his daughter, Murphy, to explore the specific environment of that planet. But the timespace around the blackhole is twisted severely, so Murphy must get started researching this strange timespace. 
    She found that every single person can avoid the influence from the twisted timespace by spliting the space with some hyperplanes into many parts. Then each person can hide into a part and he will not get influented. 
    The hyperplane means that, for example, in 3-dimensional space, whose hyperplane is a 2-dimensional space that is a plane; and in 2-dimensional space, whose hyperplane is 1-dimensional space that is a line. So a n-dimensional space whose hyperplane is (n-1)-dimensional space.
    So Murphy want you to help her find out the result of how many different parts a n-dimensional space can be splited mostly by m hyperplanes.

Input

The first line of input is an integer T(1 <= T <= 100000) represents the number of cases.
Then there will be T lines following, each line is a case of two integer n(1 <= n <= 5) and m(0 <= m <= 16000) represent a n-dimensional space and m hyperplanes.

Output

There will be T lines output and the ith line is the result of the ith case. 

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期末联赛的更多相关文章

  1. 第十八次CSP认证游记 | 2019.12.15

    CSP认证的考试是Haogod介绍的,取得一定成绩之后能有机会参加CCSP的分赛区和全国决赛.这次来参加认证要感谢老师的奔走为我们申请学校的报销,虽然最终因为这不是比赛所以报名费和差旅费下不来,但是老 ...

  2. NOI2019退役记 upd:2019.12.1

    (我把原来写的东西全部删掉了) AFO. 我退役了,\(\mbox{yyb}\)退役了. 至少,在接下来的日子里,我得投身到文化课,度过快乐的高三生活了. 这两年的\(OI\)生涯给了我很多,让我学会 ...

  3. Tencent Cloud Developers Conference(2018.12.15)

    时间:2018.12.15地点:北京朝阳悠唐皇冠假日酒店

  4. Data truncation: Incorrect datetime value: 'May 15, 2019 4:15:37 PM

    因为系统在windows下测试过是正常的 windows下的jdk+ windows下安装的mysql 全部cases通过 linux下的jdk + windows下安装的mysql 新增和更新,影响 ...

  5. MyBatis 配置/注解 SQL CRUD 经典解决方案(2019.08.15持续更新)

    本文旨在记录使用各位大神的经典解决方案. 2019.08.14 更新 Mybatis saveOrUpdate SelectKey非主键的使用 MyBatis实现SaveOrUpdate mybati ...

  6. IDEA下将dubbo简单项目跑Demo(2019.12版)

    项目架构(聚合项目,父子模块) src没用,所以删去 选择maven项目,不用勾选模板骨架,直接main方法,因为不用到服务器 顺序是按照:添加pom依赖-接口实现类-配置文件 项目环境 IDE:In ...

  7. 2021.12.15 P2328 [SCOI2005]超级格雷码(找规律填空)

    2021.12.15 P2328 [SCOI2005]超级格雷码(找规律填空) https://www.luogu.com.cn/problem/P2328 题意: 输出n位B进制的格雷码. 分析: ...

  8. OI生涯回忆录 2018.11.12~2019.4.15

    上一篇:OI生涯回忆录 2017.9.10~2018.11.11 一次逆风而行的成功,是什么都无法代替的 ………… 历经艰难 我还在走着 一 NOIP之后,全机房开始了省选知识的自学. 动态DP,LC ...

  9. [JZOJ5977] 【清华2019冬令营模拟12.15】堆

    题目 其中n,q≤500000n,q\leq 500000n,q≤500000 题目大意 让你维护一个堆.支持一下操作: 在某个点的下面加上另一个点,然后进行上浮操作. 询问某一点的权值. 思考历程 ...

随机推荐

  1. 操作系统之LRU算法 C语言链表实现

    LRU是Least Recently Used的缩写,即最近最少使用,是一种常用的页面置换算法,选择最近最久未使用的页面予以淘汰.该算法赋予每个页面一个访问字段,用来记录一个页面自上次被访问以来所经历 ...

  2. bzoj1191 超级英雄

    Description 现在电视台有一种节目叫做超级英雄,大概的流程就是每位选手到台上回答主持人的几个问题,然后根据回答问题的多少获得不同数目的奖品或奖金.主持人问题准备了若干道题目,只有当选手正确回 ...

  3. SQL Server 记录(更新中...)

    sys.databases 显示所有数据库信息 sys.tables 显示当前数据库所有的表的信息 Go 向 SQL Server 实用工具发出一批 Transact-SQL 语句已结束的信号,Go本 ...

  4. 使用php实现单点登录实例详解

    1.首先准备两个虚拟域名 127.0.0.1 www.openpoor.com 127.0.0.1 www.myspace.com 2.在openpoor的根目录下创建以下文件 index.php文件 ...

  5. 解决/home磁盘空间不足问题

    最近在Linux下做仿真实验,但是渐渐的发现,/home原来分配的空间不足.通过先建硬盘分区,然后挂载到/home文件的方法,在网上查了好多资料 建立分区并挂载分区http://www.se126.c ...

  6. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  7. git push的时候每次都要输入用户名和密码的问题解决

    换了个ssh key,发现每次git push origin master的时候都要输入用户名和密码 原因是在添加远程库的时候使用了https的方式..所以每次都要用https的方式push到远程库 ...

  8. Libev源码分析04:Libev中的相对时间定时器

    Libev中的超时监视器ev_timer,就是简单的相对时间定时器,它会在给定的时间点触发超时事件,还可以在固定的时间间隔之后再次触发超时事件. 所谓的相对时间,指的是如果你注册了一个1小时的超时事件 ...

  9. 像Google一样构建机器学习系统3 - 利用MPIJob运行ResNet101

    本系列将利用阿里云容器服务,帮助您上手Kubeflow Pipelines. 第一篇:在阿里云上搭建Kubeflow Pipelines 第二篇:开发你的机器学习工作流 第三篇:利用MPIJob运行R ...

  10. 基于TableStore的海量气象格点数据解决方案实战

    前言 气象数据是一类典型的大数据,具有数据量大.时效性高.数据种类丰富等特点.气象数据中大量的数据是时空数据,记录了时间和空间范围内各个点的各个物理量的观测量或者模拟量,每天产生的数据量常在几十TB到 ...