codeforces #232 div2 解题报告
A:简单题;我们可以把点换成段处理,然后枚举段看是否被霸占了;
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int b[];
int main()
{
int n;
cin>>n;
int l,r;
cin>>l>>r;
for (int i=l;i<r;i++)
b[i+]=;
for (int i=;i<=n;i++)
{
cin>>l>>r;
for (int i=l;i<r;i++)
if (b[i+]) b[i+]=;
} int sum=;
for (int i=;i<=;i++)
if (b[i]) sum++;
cout<<sum<<endl;
return ;
}
B:数学题,题目越长越简单,这个道理没错啊,开始没推出来,猜了个结论;
可以达到的值的范围是[L,R],[2*L,2*R],[3*L,3*R],......[X*L,X*R],只可能是这些结果。。
所以XL<=ni<=X*R;
结论就是:
if (a/l*l<=a&&a/l*r>=a) cout<<"Yes"<<endl;
C题:题目简单,但是很难,没做出来。。。。
大概思路是:先将每个书分解质因数CI,然后将这CI个质因数分配到N个盒子里,组合数学求这个方案数:AI=C(ci+n-1,n-1);ps:我还推不出这个等式啊。。。。。
ANS=a[i]乘积%10000000007;
对了求C(N,M)=C(N-1,M-1)+C(N,M-1)可以运用数组求出
#include<iostream>
#include<algorithm>
#include<string.h>
#include<map>
using namespace std;
map<int,int> v;
const int mod=;
int c[][];
int n,a[],cnt=;
long long num[]; void getnum(int x)
{
for (int i=;i*i<=x;i++)
{
while (x%i==) {
if (v.count(i))
{
num[v[i]]++;
x/=i;
}
else{
v[i]=++cnt;
num[v[i]]++;
x/=i;
}
}
}
if (x==) return;
if (v.count(x))
num[v[x]]++;
else
{
v[x]=++cnt;
num[v[x]]++;
}
} int main()
{
c[][]=;
for (int i=;i<=;i++)
for (int j=;j<=i&&j<=;j++)
{
if (j==||j==i) c[i][j]=;
else
c[i][j]=(c[i-][j-]+c[i-][j])%mod;
} int n;
cin>>n;
for (int i=;i<=n;i++)
{
int x;
cin>>x;
getnum(x);
} long long ans=;
for (int i=;i<=cnt;i++)
ans=ans*c[num[i]+n-][n-]%mod;
cout<<ans<<endl;
return ;
}
D题:个人认为这题比C简单,赛后wo耐心的把公式推出了,其实也比较好推的
ANS:(v[i]-2)u[i]+2*(n-v[i]+1) / (2*u[i]*v[i]);
卡在求U[I],V[I];
居然有这样的神结论:因为10^9的素数很密集,可以直接暴力求解,吓尿了。。。。
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h> using namespace std;
int prime[];
int cnt=;
int vis[+]; void init()
{
for (int i=;i<=;i++){
if (vis[i]) continue;
prime[++cnt]=i;
for (int j=i+i;j<=;j+=i)
vis[j]=;
}
} long long gcd(long long x,long long y)
{
if (x<y) swap(x,y);
if (x%y==) return y;
return gcd(y,x%y);
} long long find1(long long x)
{
while ()
{
int i=;
while (i<=cnt)
{
if (x%prime[i]==&&x!=prime[i]) {x--;i=;continue;}
i++;
}
return x;
}
} long long find2(long long x)
{
x++;
while ()
{
int i=;
while (i<=cnt)
{
if (x%prime[i]==&&x!=prime[i]) {x++;i=;continue;}
i++;
}
return x;
}
} int main()
{
int n;
init();
cin>>n;
for (int i=;i<=n;i++)
{
int x;
cin>>x;
long long l=find1(x),r=find2(x);
long long a=(l-)*r+*(x-l+),b=*(l*r);
cout<<a/gcd(a,b)<<"/"<<b/gcd(a,b)<<endl;
} return ;
}
可见我弱的一般性。。。
codeforces #232 div2 解题报告的更多相关文章
- Codeforces #263 div2 解题报告
比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...
- Codeforces Round#320 Div2 解题报告
Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...
- Codeforces Round #299 Div2 解题报告
这场比赛并没有打现场,昨天晚上做了ABCD四道题,今天做掉了E题 以前还没有过切完一场比赛的所有题呢~爽~ A. Tavas and Nafas Today Tavas got his test ...
- codeforces 31C Schedule 解题报告
题目链接:http://codeforces.com/problemset/problem/31/C 题目意思:给出 n 个 lessons 你,每个lesson 有对应的 起始和结束时间.问通过删除 ...
- codeforces 499B.Lecture 解题报告
题目链接:http://codeforces.com/problemset/problem/499/B 题目意思:给出两种语言下 m 个单词表(word1, word2)的一一对应,以及 profes ...
- codeforces 495C. Treasure 解题报告
题目链接:http://codeforces.com/problemset/problem/495/C 题目意思:给出一串只有三种字符( ')','(' 和 '#')组成的字符串,每个位置的这个字符 ...
- codeforces 490B.Queue 解题报告
题目链接:http://codeforces.com/problemset/problem/490/B 题目意思:给出每个人 i 站在他前面的人的编号 ai 和后面的人的编号 bi.注意,排在第一个位 ...
- CodeForces 166E -Tetrahedron解题报告
这是本人写的第一次博客,学了半年的基础C语言,初学算法,若有错误还请指正. 题目链接:http://codeforces.com/contest/166/problem/E E. Tetrahedro ...
- codeforces 489A.SwapSort 解题报告
题目链接:http://codeforces.com/problemset/problem/489/A 题目意思:给出一个 n 个无序的序列,问能通过两两交换,需要多少次使得整个序列最终呈现非递减形式 ...
随机推荐
- OJ推荐【转】
来自:http://blog.csdn.net/zdp072/article/details/16207111 一. Online Judge简介: Online Judge系统(简称OJ)是一个在线 ...
- 种树 (codevs 1653) 题解
[问题描述] 一条街的一边有几座房子.因为环保原因居民想要在路边种些树.路边的地区被分割成块,并被编号为1..n.每个块大小为一个单位尺寸并最多可种一棵树.每个居民想在门前种些树并指定了三个号码b,e ...
- SQLite数据库管理的相关命令
1.创建数据库 启动命令行,通过输入如下命令打开Shell模式的CLP: sqlite3 test.db 虽然我们提供了数据库名称,但如果该数据库不存在,SQLite实际上就未创建该数据库,直到在数据 ...
- 压力测试之TCPP
1.下载源码 tpcc-mysql-src.tgz 2.解压 tpcc-mysql-src.tgz 3.安装 [root@DBMysql mysql]# cd /home/mysql/tpcc-mys ...
- 十天学会单片机Day3 D/A与A/D转换器
D/A转换器 1.二进制权电阻网络型D/A转换器 基准电压Vref 数据D(d3d2d1d0) 输出模拟电压V0 i0 = Vref/8R i1 = Vref/4R i2 = Vref/ ...
- openstack的第二天
今天,在公司测试了还是网络有问题. 但是用了rdo还是成功了~明天就再试试怎么开放端口进来.
- Python脚本控制的WebDriver 常用操作 <一> 启动浏览器
由于本人的学习定位是基于Selenium+WebDriver+Python+FireFox+Eclipse+Pydev, 所以我的笔记也只和这方面相关. 我打算先学习基于Python脚本WebDriv ...
- openshift云计算平台diy模式安装Python2.7+Flask
主要翻译了链接1)的教程,加上一些个人研究,步骤如下: 1) 在openshift.redhat.com申请账号,安装git for windows,然后安装gem install rhc,这些比较容 ...
- 排序 选择排序&&堆排序
选择排序&&堆排序 1.选择排序: 介绍:选择排序(Selection sort)是一种简单直观的排序算法.它的工作原理如下.首先在未排序序列中找到最小(大)元素,存放到排序序列的起始 ...
- hdu 4613 Points<计算几何>
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4613 题意: 判断一个集合中的点能不能由另一个集合中的点,通过平移,旋转,放缩得到~ 思路:先求出集合中的 ...