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 ...
随机推荐
- 从PC跳转至wap
<script language="JavaScript">function mobile_device_detect(url){var thisOS=navigato ...
- Windows程序设计之Hello,Windows 98程序的声音调试记录
最近在Window程序设计第五版,刚看到第三章,第三章中有一个程序调用了一个多媒体对象库winmm.lib库,由于该库不再默认项目中,如果不手动添加,编译时会提示错误而无法运行,但是书上用的是Visu ...
- eclipse使用快捷键
注意热键冲突 内容补全键 Alt+/ 快速修复键 ctrl+1 代码移动 Alt+上下键(选中代码块) 左右移动 tab(右边)Shift+tab( ...
- smarty第一天
1.安装 安装Smarty发行版在/libs/目录里的库文件(就是解压了). 2.工作原理 美工人员 1. 写模板, HTML CSS JavaScript 2. 使用Smarty表现逻辑 放变量, ...
- jquery跨域调用wcf
使用jquery跨域调用wcf服务的时候会报如下错误 $.ajax({ url: 'http://localhost:28207/Service1.svc/GetData', method: 'get ...
- linux网络子系统内核分析
1.选择路由 若要将数据包发至PC2,则linux系统通过查询路由表可知168.1.1.10(目的地址)的网关地址为192.168.1.1,此时linux系统选择网卡1发送数据包. 2.邻居子系统(通 ...
- pure css做的pc登陆界面
源码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...
- Git - Tutorial [Lars Vogel]
From: http://www.vogella.com/tutorials/Git/article.html Git - Tutorial Lars Vogel Version 5.6 Copyri ...
- Supporting Connected Routes to Subnet Zero
Supporting Connected Routes to Subnet Zero IOS allows the network engineer to tell a router to eithe ...
- iframe 父子窗口相互之间调用语法
一.父窗口调用iframe子窗口方法 1.HTML语法:<iframe name="myFrame" src="child.html"></i ...