codeforces #240 div 2
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的更多相关文章
- Codeforces #344 Div.2
Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...
- Codeforces #345 Div.1
Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...
- Codeforces Beta Round #27 (Codeforces format, Div. 2)
Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...
- Codeforces#441 Div.2 四小题
Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...
- codeforces #592(Div.2)
codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...
- codeforces #578(Div.2)
codeforces #578(Div.2) A. Hotelier Amugae has a hotel consisting of 1010 rooms. The rooms are number ...
- codeforces #577(Div.2)
codeforces #577(Div.2) A Important Exam A class of students wrote a multiple-choice test. There are ...
- codeforces #332 div 2 D. Spongebob and Squares
http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...
- 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 ...
随机推荐
- 【原】简述使用spark集群模式运行程序
本文前提是已经正确安装好scala,sbt以及spark了 简述将程序挂载到集群上运行的步骤: 1.构建sbt标准的项目工程结构: 其中: ~/build.sbt文件用来配置项目的基本信息(项目名 ...
- DOS下无法调出中文输入法-Solved
From:http://www.cnblogs.com/killerlegend/p/3750542.html Author:KillerLegend Date:2014.5.24 DOS下无法打开中 ...
- List GetEnumerator
static void Main() { List<int> list = new List<int>(); list.Add(); list.Add(); list.Add( ...
- Mongodb初学习--安装、试用
MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案. 在MongoDB中数据被分组存储在数据集中,被称为一个集合(Collection ...
- WCF 内存入口检查失败
WCF 内存入口检查失败 Memory gates checking failed 异常信息:内存入口检查失败,因为可用内存(xxx 字节)少于总内存的 xx%.因此,该服务不可用于传入的请求.若 ...
- 浅析python的string.Template
摘自:python参考手册. string模块定义了一种新字符串类型Template,简化了特定的字符串置换操作, Template定义一个类 1.template(s), #s是字符串 s='he ...
- 使用supervisor的一些注意事项
一直都有在使用supervisor来管理linux上的服务进程.最近有同事说有某服务貌似有问题,让上去检查一下.上去以后发现某服务反应的确很慢,所以就用supervisor重启一下.但是重启的时候就发 ...
- 内核堆分配函数brk()源码分析
Evernote公开链接:http://www.evernote.com/shard/s133/sh/5b8d3b26-0e53-4c61-aa43-66f6e87bbcb7/a44096dd557f ...
- android几种定时器机制及区别
在android中,经常用到的定时器主要有以下几种实现:一.采用Handler与线程的sleep(long )方法二.采用Handler的postDelayed(Runnable, long) 方法三 ...
- OpenStack:安装Glance
>安装Glance1. 安装# apt-get install glance python-glanceclient删除sqlite文件rm -f /var/lib/glance/glance. ...