题目列表:

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. 【JZOJ4803】【NOIP2016提高A组模拟9.28】求导

    题目描述 输入 输出 样例输入 2x^2+3x+1 样例输出 4x+3 数据范围 样例解释 求导的意思: 多项式是由若干个单项式构成的 单项式的一般形式是ax^b,其中ab都是常数,x是自变量 对于单 ...

  2. hdu3917 最大权闭合图

    题意:有N个城市,M个公司.现在需要建立交通是获得的利益最大.如果2个公司A,B, A修的路为Xa->Ya,B的路为Xb->Yb,如果Ya==Xb,那么这2个公司有关系. 对于每个公司都有 ...

  3. Java程序中如何使用事物

    在java操作数据库是,为了保证数据的一致性,比如转账操作,从一个账户减掉10元,在另一个账户加上10元. 在类中定义的成员属性(变量)不用赋初值,但在函数里头定义的变量就一定要赋初值. packag ...

  4. Ubuntu官方源

    由于国内使用官方源导致下载速度慢等各方面原因,很多人将官方源替换成阿里源等,但是某些应用安装会报错.现将官方源分享如下: 备份当前源: 执行命令:# sudo cp /etc/apt/sources. ...

  5. Oracle使用——impdp导入数据时数据表已经存在

    背景 在做数据迁移时,需要将不同地方的dmp文件整合到一个数据库中,在导入时,目标表已经存在,该如何把数据追加进入目标表中 方法介绍 当使用IMPDP完成数据库导入时,如遇到表已存在时,Oracle提 ...

  6. 《DL/T 1476-2015 电力安全工器具预防性试验规程》中的样品名称及试验项目

  7. Spring中配置DataSource数据源的几种选择

    从JNDI获得DataSource. 从第三方的连接池获得DataSource. 使用DriverManagerDataSource获得DataSource. 一.从JNDI获得DataSource ...

  8. MySQL按时间统计每个小时记录数

    MySQL按时间统计每个小时记录数 方案1: ? 1 2 3 4 5 6 7 SELECT  @rownum := @rownum + 1 AS ID,         CONCAT((CASE WH ...

  9. WPF疑难杂症之二(全屏幕窗口)

    原文:WPF疑难杂症之二(全屏幕窗口) 近日的学习中遇到一个非常奇怪的问题:用XAML文件创建了一个全屏幕窗口,然后,在窗口中建立了一个非常简单的动画.一切都在我的掌控之中,实现非常的顺利. WPF中 ...

  10. NSOperation 详解

    原文地址:http://nshipster.com/nsoperation/ 大家都知道的秘密是一个应用程序,瞬间响应卸载计算在后台异步完成.因此,现代的Objective-C开发者有两种选择:大中央 ...