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 ...
随机推荐
- C语言-sizeof()与strlen()的区别【转】
先看看sizeof() 一.sizeof的概念 sizeof是C语言的一种单目操作符,如C语言的其他操作符++.--等.它并不是函数.sizeof操作符以字节形式给出了其操作数的存储大小.操作数可以是 ...
- python 数据类型(sequence 序列、dictionary 词典、动态类型)
文章内容摘自:http://www.cnblogs.com/vamei 1.sequence 序列 sequence(序列)是一组有顺序的元素的集合 (严格的说,是对象的集合,但鉴于我们还没有引入“对 ...
- EMVTag系列9《卡片管理数据》
Ø 5F30 服务码 F: n 3 T: 5F30 L: 2 -O(可选):可选数据元 按GB/T 17552标准,卡片中的服务码(5F30) 的值,要和二磁道等效数据57中的服务码的值完全一 ...
- DB2物化表
DB2物化查询表(MQT)是DB2数据库中一类特殊的表 物化表和视图的区别 物化表是一个查询结果集,视图是一个SQL语句. 以下是一个简单例子(说明物化表) 1.创建表,插入测试数据 ----创建表 ...
- 部分手机不能连PC adb
http://www.th7.cn/Program/java/201407/232139.shtml 1. 命令行中执行 android update adb [这一步的目的是产生下面第二步的路径和文 ...
- ios中怎么获得当前版本号
NSString *version = [NSBundle mainBundle].infoDictionary[(__bridge NSString *)kCFBundleVersionKey];
- Object-c 语法 - NSObject常用方法和反射
NSObject常用方法 - (BOOL)isKindOfClass:(Class)aClass //判断是否为aClass或者aClass的子类的实例,aClass可以通过[类名 class]获取 ...
- 如何安装altium designer 10
http://jingyan.baidu.com/article/4dc4084881e2bdc8d946f1f3.html
- VIM实用基本操作技巧
文本编辑器有很多,图形模式下有gedit.kwrite等编辑器,文本模式下的编辑器有vi.vim(vi的增强版本)和nano.vi和vim是Linux系统中最常用的编辑器.有人曾这样的说过在世界上有三 ...
- 带搜索框的下拉框chosen.jQury.js
下载所需js,css png资源 <link href="chosen.css" rel="stylesheet" type="text ...