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 ...
随机推荐
- ListView与.FindControl()方法的简单练习 #2 -- ItemUpdting事件中抓取「修改后」的值
原文出處 http://www.dotblogs.com.tw/mis2000lab/archive/2013/06/24/listview_itemupdating_findcontrol_201 ...
- python使用简单http协议来传送文件
python使用简单http协议来传送文件!在ubuntu环境下,局域网内可以使用nc来传送文件,也可以使用基于Http协议的方式来下载文件我们可以使用python -m SimpleHTTPServ ...
- 开始认真学计算机网络----computer network学习笔记(一)
什么是计算机网络,就是连一堆计算机,计算机不单单指pc,还包括打印机啦,手机啦巴拉巴拉一堆 为什么要连,share data共享数据 数据? 文档,图片,视频,巴拉巴拉 网络有什么类型? LAN--- ...
- 使用 libevent 和 libev 提高网络应用性能——I/O模型演进变化史
构建现代的服务器应用程序需要以某种方法同时接收数百.数千甚至数万个事件,无论它们是内部请求还是网络连接,都要有效地处理它们的操作. 有许多解决方案,但事件驱动也被广泛应用到网络编程中.并大规模部署在高 ...
- Python 爬虫实例
下面是我写的一个简单爬虫实例 1.定义函数读取html网页的源代码 2.从源代码通过正则表达式挑选出自己需要获取的内容 3.序列中的htm依次写到d盘 #!/usr/bin/python import ...
- chkconfig 命令详解
chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息.谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接. 使用语法: chkconfig [--a ...
- [原创]在Windows和Linux中搭建PostgreSQL源码调试环境
张文升http://ode.cnblogs.comEmail:wensheng.zhang#foxmail.com 配图太多,完整pdf下载请点这里 本文使用Xming.Putty和VMWare几款工 ...
- uva 11922 Permutation Transforme/splay tree
原题链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18902 伸展树的区间翻转剪切... 如下: #include< ...
- Android开发初始
由于本人一直的主攻方向是.NET平台,所以移动开发方面主要是Windows Phone平台,但是确实Windows Phone的市场占有率太小了,在加上本人是个技术迷,希望尝试新的东西,所以Andro ...
- 横屏下的ImagePickerController
Try this way.... As per Apple Document, ImagePicker Controller never Rotate in Landscape mode. You h ...