A. Dreamoon and Stairs

题意:给出n层楼梯,m,一次能够上1层或者2层楼梯,问在所有的上楼需要的步数中是否存在m的倍数

找出范围,即为最大步数为n(一次上一级),最小步数为n/2+n%2 在这个范围里找即可

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<algorithm>
using namespace std; typedef long long LL; int main()
{
int n, m,i,flag=,mn,mx;
cin>>n>>m;
mx=n;
mn=n/+n%; for(i=mn;i<=mx;i++){
if(i%m==) {
flag=;
printf("%d\n",i);
break;
}
}
if(!flag) printf("-1\n");
}

B. Dreamoon and WiFi

题意:给出两个字符串s1,s2 s1中只包含'+','-'(+代表加1,-代表-1) s2中包含'+','-','?'三种, 问s1,s2串得到相同的数值的概率

在s1中,令a[0]表示-,a[1]表示+

在s2中,令b[0]表示-,b[1]表示+,b[2]表示问号

分问号的个数为0和不为0来讨论

问号为0是:分别判断加号,减号的个数是否相等即可

问号不为0是,那么所差的加号为a[1]-b[1],即为从b[2]个位置中选出a[1]-a[0]个位置,再用这个除以总的方案数2^b[2]

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<algorithm>
using namespace std; typedef long long LL;
char s1[],s2[],a[],b[]; LL C(int n,int m){
if(n<m||n<||m<) return ;
if(m<n-m) m=n-m;
LL ans=;
for(int i=m+;i<=n;i++) ans*=i;
for(int i=;i<=n-m;i++) ans/=i;
return ans;
} int main()
{
int len1,len2,i,j,pos,pos1,tot,sum,sum1;
cin>>s1>>s2;
len1=strlen(s1);
len2=strlen(s2); // printf("c(2,3)=%d\n",C(2,3)); for(i=;i<len1;i++){
if(s1[i]=='+') a[]++;
if(s1[i]=='-') a[]++;
}
for(i=;i<len2;i++){
if(s2[i]=='+') b[]++;
else if(s2[i]=='-') b[]++;
else b[]++;
}
if(b[]==){
if(a[]==b[]&&a[]==b[]) printf("1.000000000000\n");
else printf("0.000000000000\n");
}
else{
pos1=a[]-b[];
pos=b[];
tot=;
for(i=;i<=pos;i++)
tot*=;
double ans=(C(pos,pos1)*1.0)/tot;
printf("%.12lf\n",ans);
}
return ;
}

C. Dreamoon and Sums

题意:给出a,b,找出符合以下条件的x,div(x,b)/mod(x,b)=k,其中k所在范围是[1,a],其中mod(x,b)!= 0.求满足这样的条件的x的和

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<algorithm>
using namespace std; typedef long long LL;
LL mod=; int main()
{
LL a,b;
cin>>a>>b;
LL ans1=(a*(a+)/%mod*b%mod+a)%mod;
LL ans2=b*(b-)/%mod;
LL ans3=ans1*ans2%mod;
cout<<ans3<<"\n";
}

c是= =翻译的题解----

Codeforces Round #272 (Div. 2)的更多相关文章

  1. Codeforces Round #272 (Div. 2) 题解

    Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs time limit per test 1 second memory limit per ...

  2. Codeforces Round #272 (Div. 2) C. Dreamoon and Sums (数学 思维)

    题目链接 这个题取模的时候挺坑的!!! 题意:div(x , b) / mod(x , b) = k( 1 <= k <= a).求x的和 分析: 我们知道mod(x % b)的取值范围为 ...

  3. Codeforces Round #272 (Div. 2)AK报告

    A. Dreamoon and Stairs time limit per test 1 second memory limit per test 256 megabytes input standa ...

  4. Codeforces Round #272 (Div. 1) B 构造 math

    http://www.codeforces.com/contest/477/problem/C 题目大意:给你n个集合,每个集合里面有四个数字,他们的gcd是k,输出符合条件的集合中m,m为集合中最大 ...

  5. Codeforces Round #272 (Div. 2) E. Dreamoon and Strings 动态规划

    E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon h ...

  6. Codeforces Round #272 (Div. 2) D. Dreamoon and Sets 构造

    D. Dreamoon and Sets 题目连接: http://www.codeforces.com/contest/476/problem/D Description Dreamoon like ...

  7. Codeforces Round #272 (Div. 2) B. Dreamoon and WiFi dp

    B. Dreamoon and WiFi 题目连接: http://www.codeforces.com/contest/476/problem/B Description Dreamoon is s ...

  8. Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs 水题

    A. Dreamoon and Stairs 题目连接: http://www.codeforces.com/contest/476/problem/A Description Dreamoon wa ...

  9. Codeforces Round #272 (Div. 2) E. Dreamoon and Strings dp

    题目链接: http://www.codeforces.com/contest/476/problem/E E. Dreamoon and Strings time limit per test 1 ...

随机推荐

  1. 1084: [SCOI2005]最大子矩阵 - BZOJ

    Description 这里有一个n*m的矩阵,请你选出其中k个子矩阵,使得这个k个子矩阵分值之和最大.注意:选出的k个子矩阵不能相互重叠. Input 第一行为n,m,k(1≤n≤100,1≤m≤2 ...

  2. IntelliJ IDEA 文件夹重命名--解决重命名后js文件引用找不到路径报404错误

    情景: 说明:ExtJS是我后来的改的名字--原来叫extjs,可是当我把在页面的引用地址改为 src="ExtJS/.."后页面就报404错误,我把它改回之前的extjs就可以( ...

  3. ContextLoaderListener作用详解

    参考网址:http://blog.csdn.net/ysughw/article/details/8992322 ContextLoaderListener监听器的作用就是启动Web容器时,自动装配A ...

  4. OD鲜为人知的小技巧--搜索通配符(关键字)

    我看过一些OD教程,关于通配符这一点很少有人讲解(大概是我看的教程少吧)  近日通过看<黑客反汇编揭秘(第二版)>第165页了解到,原来OD还有这样方便的功能,那就是搜索通配符: Olly ...

  5. ZOJ1232 Adventure of Super Mario spfa上的dp

    很早之前听说有一种dp是在图上的dp,然后是在跑SPFA的时候进行dp,所以特地找了一题关于在SPFA的时候dp的. 题意:1~a是村庄 a+1~a+b是城堡,存在m条无向边.求由a+b->1的 ...

  6. POJ 1060 Modular multiplication of polynomials(多项式的加减乘除,除法转化成减法来求)

    题意:给出f(x),g(x),h(x)的 (最高次幂+1)的值,以及它们的各项系数,求f(x)*g(x)/h(x)的余数. 这里多项式的系数只有1或0,因为题目要求:这里多项式的加减法是将系数相加/减 ...

  7. spark在eclipse上配置

    环境:spark1.4.0,hadoop2.6.0 1.安装好jdk 2.在spark的conf目录下找到spark-env.sh.template,打开,在后面加上 export SCALA_HOM ...

  8. ubuntu下hadoop2.6在eclipse上的配置

    1.复制hadoop-eclipse-plugin-2.6.0.jar插件到eclipse的plugins目录下(hadoop2.6的插件,在hadoop自带上没有,要上网下载,多试几个 如果是从ub ...

  9. .net与linux

    Mono是什么? http://blog.sina.com.cn/s/blog_693ffe760100k5uh.html Mono是一个开放源代码,Linux版的Microsfot.NET开发平台 ...

  10. HTML5入门3---视频播放器

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta na ...