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 个无序的序列,问能通过两两交换,需要多少次使得整个序列最终呈现非递减形式 ...
随机推荐
- Delphi的"Invalid pointer operation"异常的解决办法
今天用Delphi编写了个dll,用到了TStringList来传递多参数,如下: [delphi] view plaincopy 01.function DBM_SetParam(procName: ...
- 关于js中this的疑问
学习bootstrap.js源码中被js里边的this绕的有点晕 /* ================================================================ ...
- 重定向语句Response.Redirect()方法与Response.RedirectPermanent()对搜索引擎页面排名的影响
在ASP.NET中,开发人员经常使用Response.Redirect()方法,用编程的手法,将对老的URL的请求转到新的URL上.但许多开发人员没有意识到的是,Response.Redirect() ...
- hdu 4609 3-idiots <FFT>
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4609 题意: 给定 N 个正整数, 表示 N 条线段的长度, 问任取 3 条, 可以构成三角形的概率为多 ...
- <转载>编程珠玑-位排序(bitsort)
转载:http://www.cnblogs.com/shuaiwhu/archive/2011/05/29/2065039.html 维护版权 在<编程珠玑>一书上,有一题是将一堆不 ...
- Java之有病的policy配置
使用-Djava.security.policy=xxx.policy启动安全策略, 你会想到codesource的配置如此蛋疼么? grant CodeBase "file:////D:/ ...
- MVC4.0网站发布和部署到IIS7.0上的方法【转:http://www.th7.cn/Program/net/201403/183756.shtml】
最近在研究MVC4,使用vs2010,开发的站点在发布和部署到iis7上的过程中遇到了很多问题,现在将解决的过程记录下来,以便日后参考,整个过程主要以截图形式呈现 vs2010的安装和mvc4的安装不 ...
- mvvm 模式
MVC = Massive View Controller ? 有笑话称MVC为重量级的试图控制器.仔细一想,确实存在这个问题.以UITableViewController和UITableView举个 ...
- NPOI导出Excel文件,对单元格的一些设置
HSSFWorkbook book = new HSSFWorkbook(); MemoryStream ms = new MemoryStream(); ISheet sheet = book.Cr ...
- perl连接mysql(转载)
文章来源:http://blog.sina.com.cn/s/blog_9d0445d50101czsr.html 首先需要用ppm安装DBI和DBD-mysql ,如果没有的话点击EDIT-pref ...