A:A. Nuts

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x ≥ 0)divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1sections.

You are minimalist. Therefore, on the one hand, you are against dividing some box into more than k sections. On the other hand, you are against putting more than v nuts into some section of the box. What is the minimum number of boxes you have to use if you want to put all the nuts in boxes, and you have b divisors?

Please note that you need to minimize the number of used boxes, not sections. You do not have to minimize the number of used divisors.

Input

The first line contains four space-separated integers kabv (2 ≤ k ≤ 1000; 1 ≤ a, b, v ≤ 1000) — the maximum number of sections in the box, the number of nuts, the number of divisors and the capacity of each section of the box.

Output

Print a single integer — the answer to the problem.

Sample test(s)
input
3 10 3 3
output
2
input
3 10 1 3
output
3
input
100 100 1 1000
output
1
Note

In the first sample you can act like this:

  • Put two divisors to the first box. Now the first box has three sections and we can put three nuts into each section. Overall, the first box will have nine nuts.
  • Do not put any divisors into the second box. Thus, the second box has one section for the last nut.

In the end we've put all the ten nuts into boxes.

The second sample is different as we have exactly one divisor and we put it to the first box. The next two boxes will have one section each.

花了半个多小时去理清数据的关系,开始感觉无从下手。。。我的方法是:制造相应的盒子,能放多少就尽量放到前面的盒子里面,最后统计一下就可以

#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int aa[]; //盒子能放的个数
int main()
{
    int k,a,b,v;
    cin>>k>>a>>b>>v;
    int ans=;
    for (int i=;i<=;i++)
         aa[i]=v;               初始每个盒子开始只有一个SECTION
    for (int i=;i<=;i++)
     {
         if (b==) break;
         if (b+>=k) {aa[i]+=v*(k-);b-=(k-);}  有B则先用
         else
         {
             aa[i]+=b*v;
             break;
         }
     }
    int tem=,ll;
    for (int i=;i<=;i++)
    {
        tem+=aa[i];
        if (tem>=a) {ll=i;break;}
    }
    cout<<ll<<endl;
    return ;

}

B:题意很简单,构造等差数列,求改变的数的个数最小。。

从A[1]暴力枚举就可,不知为何我从A[N]枚举就挂,白WA5次 #include<iostream>

#include<algorithm>
#include<math.h>
using namespace std;
int a[],n,k;
int main()
{
    cin>>n>>k;
    for (int i=;i<=n;i++)
    cin>>a[i];
    int ans=;
    int kk;
    for (int i=;i<=;i++)
    {
        int o=;
        int tem=i;
        for (int j=;j<=n;j++)
        {
            if (a[j]!=tem)
            o++;
            tem+=k;
        }
        if (o<ans) {ans=o;kk=i;}
    }     cout<<ans<<endl;
    if (ans==) return ;
    for (int i=;i<=n;i++)
    {
        if (a[i]>kk) {cout<<"- "<<i<<" "<<a[i]-kk<<endl;}
        else if (a[i]<kk) {cout<<"+ "<<i<<" "<<kk-a[i]<<endl;}
        kk+=k;
    }
    return ;
} C题,我是瞎搞,我的理解是使点连接的边相对稀少,先这样加边:1-->2,2-->3,3-->4,n-1-->n;先见N-1条边,然后:1-->3,2-->4,3-->5,依次;然后是:1--4,2-->5,....感觉这样相对不密集。。#include<iostream>#include<algorithm>
#include<math.h>
#include<string.h>
using namespace std;
int n,p;
int mp[][];
int main()
{
  int t;
  cin>>t;
  while (t--)
  {
      int m=*n+p;
      memset(mp,,sizeof(mp));
      cin>>n>>p;
      for (int i=;i<n;i++)
        mp[i][i+]=;
        m=*n+p;
        m=m-(n-);
            for (int i=;i<n;i++)
            {
             if (m==) break;
             for (int j=;j+i<=n;j++)
             {
                mp[j][j+i]=;
                m--;
                if (m==) break;
              }
            }
    for (int i=;i<=n;i++)
        for (int j=;j<=n;j++)
        if (mp[i][j])
        cout<<i<<" "<<j<<endl;
  }
    return ;}还有不得不吐槽自己的码代码能力,太坑了 

codeforces #236 div2 简洁题解的更多相关文章

  1. Codeforces Round div2 #541 题解

    codeforces Round #541 abstract: I构造题可能代码简单证明很难 II拓扑排序 III并查集 启发式排序,带链表 IV dp 处理字符串递推问题 V 数据结构巧用:于二叉树 ...

  2. codeforces 576 div2 A-D题解

    A题 Description 题目链接: https://codeforces.com/contest/1199/problem/A 题意: 给定长度为n(1≤n≤100000)的一个序列a,以及两个 ...

  3. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  4. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  5. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  6. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  7. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  8. Codeforces Round #543 Div1题解(并不全)

    Codeforces Round #543 Div1题解 Codeforces A. Diana and Liana 给定一个长度为\(m\)的序列,你可以从中删去不超过\(m-n*k\)个元素,剩下 ...

  9. Codeforces Round #545 Div1 题解

    Codeforces Round #545 Div1 题解 来写题解啦QwQ 本来想上红的,结果没做出D.... A. Skyscrapers CF1137A 题意 给定一个\(n*m\)的网格,每个 ...

随机推荐

  1. 6.python字符串-内置方法列举

    所谓内置方法,就是凡是字符串都能用的方法,这个方法在创建字符串的类中,下面是总结: 首先,我们要学习一个获取帮助的内置函数 help(对象) ,对象可以是一个我们创建出来的,也可以是创建对象的那个类, ...

  2. python-抓取图片

    今天看到博客园一个文章,python抓取图片,也没看内容,心想自己也写一个抓取脚本试试看,一方面自己也在学习python,另一方面毕竟实际工作也经常会遇到这种需要临时写脚本的时候,突击锻炼还是好的嘛. ...

  3. Python 有哪些优点?为何要学Python?

      1. 支持OOP编程 从根本上讲Python仍是一种面向对象的语言,支持多态.继承等高级概念,在Python里使用OOP十分容易 没有C++.Java那样复杂,但不必做Python下OOp高手,够 ...

  4. C# 页面抓取获取快递信息

    通过页面抓取信息可以获得很多我们想要的信息,比如现在常会用到的快递查询,主要抓取的网站为http://www.kuaidi100.com/ 通过IE的网络分析我们可以得到下面信息 通过对这个网站的分析 ...

  5. o2o家庭助手demo

    前段时间跟一个同事出去游玩,在回来的大巴上面我们聊到了现在比较热门的o2o,说实话我自己早就想要在这个领域好好地玩一把.但是一直苦于没有很好地idea,再加上自己之前一直没有这方面的创业经验,所以一直 ...

  6. JavaScript高级程序设计之EventUtil

    简单的通用事件方法 var EventUtil = { getEvent: function (e) { return e || window.event; }, getTarget: functio ...

  7. Mysql找不到mysql.sock怎么办?

    1. #ps -aux|grep mysql 找mysql的进程. #kill mysql进程号 确定全部kill光 2.直接跳第3步,无效再使用第2步 /usr/local/mysql/bin/my ...

  8. IOS之表视图添加搜索栏

    下面是我们要实现的效果.本效果是在上一篇自定义表视图的基础上进行更改的.     1.将Search bar and search display拖动到ViewController中.不要添加Sear ...

  9. ext4.1动态生成多个checkboxgroup(或者radiogroup),并且有toolbar操作、

    转载自:http://blog.csdn.net/zhengyuechuan/article/details/9327291 前台controller代码: Ext.define('zyc.contr ...

  10. 64.OV7725初始化配置

    所有的结局都是好的,不好,是因为你还有坚持到最好. OV7725摄像头的初始化配置,需要SCCB总线即IIC接口配置.先发送配置数据到OV7725中,然后通过随机读取对应地址的数据来验证数据是否写进去 ...