ACM 第十三天
训练赛题目
#include <bits/stdc++.h> using namespace std; int main()
{
double n,m;
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
while(cin>>n>>m){
cout<<max(ceil(n*2.0/m),2.0)<<endl;
}
}
D题代码:
方法一 数学方法
#include <bits/stdc++.h>
using namespace std;
int pow2(int a,int b)
{
int ans =;
for(int i=;i<=b;i++)
ans=(ans*)%();
return ans;
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
string s;
cin>>s;
int ans=;
for(int i=;i<s.size();i++)
{
if((s[i]=='N'||s[i]=='S') &&(s[i+]=='W'||s[i+]=='E'))
ans=(ans+)%; }
long long a1=(long long)pow2(,ans)%();
cout<<a1<<endl; return ;
}
方法二 递推思想
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
char s[];
cin>>s;
int a[];
int s1=strlen(s);
a[]=a[]=;
for(int i=;i<=s1;i++)
{
if((s[i-]=='N'||s[i-]=='S') &&(s[i]=='W'||s[i]=='E'))
a[i+]=(a[i]+a[i-])%mod;
else
a[i+]=a[i];
}
cout<<a[s1]<<endl;
return ;
}
G题:一个数是 三个素数的乘积
#include <bits/stdc++.h>
using namespace std; int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int n;
bool flag;
while(cin>>n)
{
int cnt=;
for(int i=; i*i<=n; i++)
{
flag=;
while(n%i==)
{
if(flag)
{
cnt++;
flag=;
}
n/=i;
}
}
if(n!=) cnt++;
if(cnt==) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return ;
}
ACM 第十三天的更多相关文章
- hdu 1292 "下沙野骆驼"ACM夏令营 (递推)
"下沙野骆驼"ACM夏令营 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...
- CRL快速开发框架系列教程十三(嵌套查询)
本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ...
- SCNU ACM 2016新生赛决赛 解题报告
新生初赛题目.解题思路.参考代码一览 A. 拒绝虐狗 Problem Description CZJ 去排队打饭的时候看到前面有几对情侣秀恩爱,作为单身狗的 CZJ 表示很难受. 现在给出一个字符串代 ...
- 我的MYSQL学习心得(十三) 权限管理
我的MYSQL学习心得(十三) 权限管理 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) ...
- SCNU ACM 2016新生赛初赛 解题报告
新生初赛题目.解题思路.参考代码一览 1001. 无聊的日常 Problem Description 两位小朋友小A和小B无聊时玩了个游戏,在限定时间内说出一排数字,那边说出的数大就赢,你的工作是帮他 ...
- acm结束了
最后一场比赛打完了.之前为了记录一些题目,开了这个博客,现在结束了acm,这个博客之后也不再更新了. 大家继续加油!
- 关于ACM的总结
看了不少大神的退役帖,今天终于要本弱装一波逼祭奠一下我关于ACM的回忆. 从大二上开始接触到大三下结束,接近两年的时间,对于大神们来说两年的确算不上时间,然而对于本弱来说就是大学的一半时光.大一的懵懂 ...
- 第一届山东省ACM——Phone Number(java)
Description We know that if a phone number A is another phone number B’s prefix, B is not able to be ...
- 第一届山东省ACM——Balloons(java)
Description Both Saya and Kudo like balloons. One day, they heard that in the central park, there wi ...
随机推荐
- 慎使用sql的enum字段类型
在sql的优化中,会有同学提到一点:使用enum字段类型,代替其他tinyint等类型.以前这也是不少人喜欢优化的,但是现在细想,是非常不合理的. 优点: 1.可以设置区间范围,比如设置性别:1男2女 ...
- Linux中Kibana部署
1.下载kibana安装包kibana-5.5.0-linux-x86_64.tar.gz tar –xzf kibana-5.5.0-linux-x86_64.tar.gz解压 把文件移动到 Mv ...
- 启动pip时,< Fatal error in launcher: Unable to create process using '"' >问题的原因及解决方法
根本原因 要启动的pip程序,中指定的python程序路径不对 实例分析 我的window电脑上同时安装了python2.7和python3.6,他们的安装路径如下图: 注意图python2.7中红线 ...
- Redis集群进阶之路
Redis集群规范 本文档基于Redis 3.X或更高版本,讲解Redis集群算法以及设计原理.此官方文档长期更新且随着Redis新版本特性的变化变动,详细请留意官网. 官网地址:https://re ...
- 对Python语法简洁的贴切描述
很多人认为,Python与其他语言相比,具有语法简洁的特点.但这种简洁到底体现在哪些地方,很少有人能说清楚.今天看到一个对这一问题的描述,个人觉得很不错,原文如下: “Python语法主要用来精确表达 ...
- 分治与递归-找k个临近中位数的数
问题描述:给定由n个互不相同的数组成的集合S以及正整数k≤n,试设计一个O(n)时间算法找出S中最接近S的中位数的k个数. 算法描述: 用线性时间选择实现的算法找到中位数 S’=除去中位数外的S S& ...
- linux 查看内置命令
使用: man shell builtins 查找结果如下:
- mybatis入门(一):jdbc的缺点
mybatis的基础内容 1.mybatis的框架原理 2.mybatis开发dao两种方法: a.原始dao开发方法(程序需要编写dao接口和dao实现类) b.mybatis的mapper接口(相 ...
- MapWinGIS使用
.net语言中使用MapWinGIS.ocx http://www.cnblogs.com/kekec/archive/2011/03/30/1999709.html 基于MapWinGis的开发探索 ...
- Codevs1332_上白泽慧音_KEY
题目传送门 裸的模板题,Tarjan求联通量. code: #include <cstdio> #include <vector> #define min(a,b) a< ...