题目列表:

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. python的解释器类型

    Python解释器 当我们编写Python代码时,我们得到的是一个包含Python代码的以.py为扩展名的文本文件.要运行代码,就需要Python解释器去执行.py文件. 由于整个Python语言从规 ...

  2. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十章:阴影贴图

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十章:阴影贴图 本章介绍一种在游戏和应用中,模拟动态阴影的基本阴影 ...

  3. 【水滴石穿】react-native-template-app

    这个也是一个基础项目 地址如下https://github.com/ndlonghi/react-native-template-app 点击登陆跳转到首页 分析代码如 react-native-te ...

  4. dsadsa

    1.Swift预览 一般来说,编程语言教程中的第一个程序是在屏幕上打印“Hello, world”.在 Swift 中,可以用一行代码实现: println("Hello, world&qu ...

  5. 【Mysql的那些事】数据库之ORM操作

    1:ORM的基础操作(必会) <1> all(): 查询所有结果 <2> filter(**kwargs): 它包含了与所给筛选条件相匹配的对象 <3> get(* ...

  6. hdu1527 威佐夫博奕

    有2堆石子,有2个人,每个人可以从一堆取或从2堆取一样的个数的石子,至少取1个.问先手的是胜或输.设(ak,bk)我么成为局势. (0,0)(1,2)(3,5)(4,7)..这种先手必输的叫奇异局势. ...

  7. MySQL命令行分号无法结束问题解决

    背景:输入一串查询语句,以分号结束,发现没有结束,再打回车,分号,还是不完.什么exit,quit,bye,都不顶用如果要ctrl+C吧,又得退出mysql,一切重来,很麻烦.后来终于发现,引起这种现 ...

  8. wepy ——$apply

    1.说明 在异步函数中更新数据的时候,必须手动调用 $apply 方法. 2.代码和效果 // html <button type="primary" plain=" ...

  9. @atcoder - AGC034E@ Complete Compress

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个 N 个点的树,编号为 1, 2, ..., N.第 i ...

  10. ping的使用

    ping -t cnblogs.com 可以一直ping网址显示对应的响应时间