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. 在云服务器搭建WordPress博客(三)安装WordPress

    WordPress的安装在Windows环境下非常简单. 安装前的准备 1.下载最新版的 WordPress,解压后,将WordPress文件夹里面的所有文件,上传到你的主机空间域名所绑定的根目录. ...

  2. Python标准库之os模块

    1.删除和重命名文件 import os import string def replace(file, search_for, replace_with): # replace strings in ...

  3. 1833: [ZJOI2010]count 数字计数 - BZOJ

    Description给定两个正整数a和b,求在[a,b]中的所有整数中,每个数码(digit)各出现了多少次.Input输入文件中仅包含一行两个整数a.b,含义如上所述.Output输出文件中包含一 ...

  4. 在Eclipse中使用Propertites Editor插件来解决property文件中文显示乱码

    在一般情况下,propertites文件在eclipse中的显示中文一直显示乱码,想要解决这个问题,需要通过在eclipse中安装一个Propertites Editor插件来进行解决. 在Eclip ...

  5. 【BZOJ】【2157】旅游

    LCT 直到动手写拆边为点的时候才发现根本不会写……去orz了一下Hzwer(话说这题应该也用不着LCT吧……下次再换种姿势写一遍好了) /****************************** ...

  6. 【BZOJ】【2844】albus就是要第一个出场

    高斯消元解XOR方程组 srO  ZYF  Orz 膜拜ZYF…… http://www.cnblogs.com/zyfzyf/p/4232100.html /******************** ...

  7. SpringMVC数据绑定全面示例(复杂对象,数组等)

    点击链接查询原文 http://www.xdemo.org/springmvc-data-bind/ 已经使用SpringMVC开发了几个项目,平时也有不少朋友问我数据怎么传输,怎么绑定之类的话题,今 ...

  8. PHP 开发中的外围资源性能分析(二)

    暂且不讨论「PHP 是不是最好的编程语言」,本文我们将分别分析一下在 PHP 程序的后端外围资源和前端外围资源,它们对整个 PHP Web 应用体验的影响,这往往比语言本身大得多. 上一篇中我们分析了 ...

  9. POJ 3411 Paid Roads(SPFA || DFS)

    题目链接 题意 : 要从1城市到n城市,求最短路是多少,从a城市到达b城市的路程,如果你到过c城市,则需要走p,否则走r长. 思路 : 因为可以来回走,所以不能用单纯的最短路,可以用二维SPFA,状态 ...

  10. struts2学习笔记(4)——数据类型转换

    回过头来看昨天的那个例子. 在昨天的例子中,只转换了一个Point类,如果想转换多个Point类怎么办呢?在昨天的例子上面做一个小的修改. 首先在input.jsp页面中修改几个输入框. <s: ...