A:语文题,估计大家都会,

B题:假如答案是ans,求最大的ans,是w*a/b==(w-ans)*a/b;

明显的二分,可是我的二分写的没水准,还有是直接做:

#include<string.h>

#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int main()
{
    int n;
    long long a,b;;
    cin>>n>>a>>b;
    for (int i=;i<=n;i++)
    {
        long long x;
        cin>>x;
        long long w=x*a/b;
        cout<<(x*a-w*b)/a<<" ";//自己手算应该能理解什么意思吧
    }
    return ;

}

C:我 lastest blood,最后一分钟PASS,囧

我的思路是:ai可以很大,那么a1,a2就用掉了k-(n/2-1) points,那么剩下的每1对数就1POINTS,假如N为奇数,a[n]=a[n-1]+1;

因为a[i]可以大于k的9倍,所以答案不会超,代码又很短。。。

#include<iostream>
using namespace std;
int a[];
int n,k;
int main()
{
    cin>>n>>k;//判断
    if (n==&&k==){
    cout<<<<endl;
    return ;
    }
    if (n==&&k||n/>k)
    {
        cout<<-<<endl;
        return ;
    }
    int t=k-n/+;//a[1]赋值
    cout<<t<<" "<<t*;//输出a[1],a[2];
    for (int i=;i<=n;i++)
    cout<<" "<<t*+i-;
    return ;

}

D:没时间看了,比赛只看的一分钟,

状态方程:f[i][j]=(f[i][j]+f[i-1][k])%10^9+7;K能被J整除,i:数组长度,j:最后一位数

#include<iostream>

#include<string.h>
using namespace std;
long long  f[][];
int num[][];
const int maxn=;
int n,k;
int main()
{
    for (int i=;i<=;i++)
    for (int j=;j<=i;j++)
    if (i%j==) num[i][++num[i][]]=j;     cin>>n>>k;
    for (int i=;i<=n;i++)
    f[][i]=;
    for (int i=;i<=k;i++)
    for (int j=;j<=n;j++)
    {
    for (int b=;b<=num[j][];b++)
    f[i][j]=(f[i][j]+f[i-][num[j][b]])%maxn;
    }
    long long ans=;
    for (int i=;i<=n;i++)
    ans=(ans+f[k][i])%maxn;
    cout<<ans<<endl;
    return ;
}

看起来O(N*k*k);我们可以先预处理因子,再直接用

大概O(n*m*最多的因子数);最多的因子数不会很大的

代码又很短。

codeforces #240 div 2的更多相关文章

  1. Codeforces #344 Div.2

    Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...

  2. Codeforces #345 Div.1

    Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...

  3. Codeforces Beta Round #27 (Codeforces format, Div. 2)

    Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...

  4. Codeforces#441 Div.2 四小题

    Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...

  5. codeforces #592(Div.2)

    codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...

  6. codeforces #578(Div.2)

    codeforces #578(Div.2) A. Hotelier Amugae has a hotel consisting of 1010 rooms. The rooms are number ...

  7. codeforces #577(Div.2)

    codeforces #577(Div.2) A  Important Exam A class of students wrote a multiple-choice test. There are ...

  8. codeforces #332 div 2 D. Spongebob and Squares

    http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...

  9. Codeforces Round #240 (Div. 2)->A. Mashmokh and Lights

    A. Mashmokh and Lights time limit per test 1 second memory limit per test 256 megabytes input standa ...

随机推荐

  1. Hao123这个流氓

    Author:KillerLegend Date:2014.2.27 From:http://www.cnblogs.com/killerlegend/p/3572591.html Hao123真让人 ...

  2. 获取月份对应的day

    function getDaysInMonth(month, year) { , , , , , , , , , , , ]; //主要处理二月份的天数 ) && (year % == ...

  3. css 串联选择器和后代选择器

    串联选择器:作用在同一个标签上 <div class=”a” id ="qq"><span>look at the color</span>&l ...

  4. [目录]Pentaho Kettle解决方案:使用PDI构建开源ETL解决方案

    第一部分:开始 1         ETL入门 1.1   OLTP和数据仓库对比 1.2   ETL是什么 1.2.1          ETL解决方案的演化过程 1.2.2          ET ...

  5. hdu 1113 Word Amalgamation

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 字符串简单题: stl水过 如下: #include<algorithm> #inc ...

  6. Windows Phone中Wallet钱包的使用

    前言 Windows Phone 8中加入了钱包Wallet这个功能,这个功能非常的有意思,开发者可以通过Wallet提供的API创建获取Wallet中的商品.统一管理用户的收集优惠券.信用卡.成员资 ...

  7. HTTP网页错误代码大全带解释

    HTTP网页错误代码大全带解释 HTTP 400 - 请求无效HTTP 401.1 - 未授权:登录失败HTTP 401.2 - 未授权:服务器配置问题导致登录失败HTTP 401.3 - ACL 禁 ...

  8. Go语言类型switch

    switch还可以用于判断变量类型.使用方式为T.(type),即在变量后加上.(type).见代码: package main import ( "fmt" ) func mai ...

  9. Effective Objective-C 2.0之Note.03(属性详解)

    用Objective-C等面向对象语言编程时,“对象”(object)就是“基本构造单元”(building block),开发者可以通过对象来存储并传递数据.在对象之间传递数据并执行任务的过程就叫做 ...

  10. Client–server model

    Client–server model From Wikipedia, the free encyclopedia The client–server model of computing ] Oft ...