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 ...
随机推荐
- 用delphiXE7 dbExpress Framework提供的功能获取数据表信息
uses + Data.DBXMetaDataNames procedure TMainForm.Button2Click(Sender: TObject);var Cmd: TDBXComman ...
- ListView与.FindControl()方法的简单练习 #2 -- ItemUpdting事件中抓取「修改后」的值
原文出處 http://www.dotblogs.com.tw/mis2000lab/archive/2013/06/24/listview_itemupdating_findcontrol_201 ...
- MHA命令系统介绍 --masterha_master_switch
常用参数介绍 --master_state=dead 强制的参数,参数值为"dead" 或者 "alive" . 如果 设置为 alive 模式,masterh ...
- MVC中的奇葩错误,参数转对象
在使用MVC中遇到一个神奇的错误,特此记录(我在用MVC4时遇到) 上面两张图就是一个变量名进行了修改,其他不变!form里面的参数也是一样的!喜欢尝试的可以尝试一下! 我的变量使用action时出现 ...
- EXCLE图形插入实例
根据所给名称找到相应图片,并进行导入. 代码如下: Sub Import_picture() For Each shap In Sheet1.Shapes '在sheet1中的图片对象进行循环 If ...
- [SRH.Docker] HBase Java 第一天学习记录
主要对HBase Table 的 简单操作, 直接上代码吧!!! http://pan.baidu.com/s/1hqzTTze ui92
- ZLG_GUI配置与函数介绍
http://www.docin.com/p-825479457.html ZLG_GUI配置与函数介绍
- iOS学习之界面通信
一.属性传值 在SecondViewController.h里 #import <UIKit/UIKit.h> @interface SecondViewController : UIVi ...
- IOS之表视图添加搜索栏
下面是我们要实现的效果.本效果是在上一篇自定义表视图的基础上进行更改的. 1.将Search bar and search display拖动到ViewController中.不要添加Sear ...
- TcpClient 错误"不能做任何连接,因为目标机器积极地拒绝它" 的解决
TcpClient 错误"不能做任何连接,因为目标机器积极地拒绝它" 的解决 //以下是tcpclient服务器端的监听程序,假设服务器端和客户端在同一台机器上,//为了使客户端可 ...