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. HTTP 错误 404.3 - Not Found由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射

    出现此错误可能是在安装IIS服务器的时候没有勾选“应用程序开发”, 解决方法如下: 就像安装IIS一样的步骤. 选择web服务器(IIS)后,再选择“应用程序开发”  选择asp.net  以及 服务 ...

  2. 在服务器操作系统上使用TeamViewer

    TeamViewer对于个人或非商业用途提供免费许可证,可以永久使用.但对于公司或商业用途则只提供7天试用期,试用期结束后则不能再使用. 在Windows XP等非服务器操作系统上安装TeamView ...

  3. c数组与指针

    0.数组和指针并不是相同的 我们声明数组时,同时分配了一些内存空间,用于容纳数组元素,但是当我们声明一个指针时,只分配了用于容纳指针本身的内存空间. 从这个方面也可以理解sizeof后面跟数组名和指针 ...

  4. DispatcherServlet--Spring的前置控制器作用简介

    参考网址:http://jinnianshilongnian.iteye.com/blog/1602617 Struts有一个ActionServlet,用来完成前置控制器(分发器)的功能.其实,所有 ...

  5. [转]CentOS 5.5下FTP安装及配置

    一.FTP的安装 1.检测是否安装了FTP : [root@localhost ~]# rpm -q vsftpd vsftpd-2.0.5-16.el5_5.1 否则显示:[root@localho ...

  6. MonoBehaviour.StopCoroutine

    MonoBehaviour.StopCoroutine Description Stops all coroutines named methodName running on this behavi ...

  7. 别让安全问题拖慢了 DevOps!

    DEVSECOPS 所面临的挑战 敏捷开发和 DevOps 方法的出现使软件开发的速度与质量都有所提升,但它们不经意地也为安全机构增压不少.从前的安全策略是基于静态数据的,而在产品上线前才应用这些策略 ...

  8. linq中查询列表的使用及iqueryable和list集合之间的转换

    linq中查询列表的使用及iqueryable和list集合之间的转换 比如要查询一个货架集合,但是只需要其id和name即可,可以用以下方法:先写一个model类:CatalogModel(注意该类 ...

  9. hadoop倒排索引

    1.前言 学习hadoop的童鞋,倒排索引这个算法还是挺重要的.这是以后展开工作的基础.首先,我们来认识下什么是倒拍索引: 倒排索引简单地就是:根据单词,返回它在哪个文件中出现过,而且频率是多少的结果 ...

  10. 简单易懂的现代魔法——Play Framework攻略4

    接前文:简单易懂的现代魔法——Play Framework攻略3 1.The Object 时隔2个多月,Play Framework系列又更新了,本次的主题是:利用Play Framework实现R ...