老规矩 有问题直接联系我:475517977@qq.com

A

直接暴力的for一遍,统计连续的有多少个就好了。模拟题。

#include<bits/stdc++.h>
using namespace std; int main(){
int k;
while(cin>>k){
string s;
cin>>s;
int cnt = 1;
int mx = 1;
for(int i=1;i<s.size();i++){
if(s[i]==s[i-1]){
cnt++;
mx=max(cnt,mx);
}else
cnt=1;
}
if(mx>=k){
cout<<"Lose"<<endl;
}else{
cout<<"Win"<<endl;
}
}
}

B

这道题是考察dfs的一道题目,dfs(int now,int a,int b)表示现在这个数是now,用了a个4,b个7,然后做下去就好了。

注意1000000000这个数据,答案会超过1e9的哦

#include<bits/stdc++.h>
using namespace std; long long n;
int cnt = 0;
long long ten[13];
map<long long,int>H;
long long ans = 0;
void solve(int a,int b,long long c,int len){
if(H[c])return;
if(c>10000000000LL)return;
if(a==b&&c>=n)ans=min(ans,c);
H[c]=1;
solve(a+1,b,c+ten[len]*4,len+1);
solve(a,b+1,c+ten[len]*7,len+1);
}
void solve(){
H.clear();
cnt = 0;
ans = 10000000000LL;
solve(0,0,0,0);
cout<<ans<<endl;
}
int main(){
ten[0]=1;
for(int i=1;i<13;i++)
ten[i]=ten[i-1]*10LL;
while(cin>>n)
solve();
}

C

感觉上非常麻烦的一道题,实际上你非常非常小的枚举每一个数就好了嘛(x

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<string>
#define mem(a,b) memset(a,b,sizeof(a))
#define LL __int64
#define MAX 100010
#include<iostream>
using namespace std; double a ,b ,c ,d ,l ,r; double cal(double x)
{
return fabs(a * x * x *x + b * x * x + c * x + d);
} int main()
{
while(cin>>a>>b>>c>>d>>l>>r)
{
double re = l;
double ans = cal(l);
while(r - re >= 0.01)
{
ans = max(ans,cal(re));
re += 0.01;
}
ans = max(ans,cal(r));
printf("%.2f\n",ans);
}
return 0;
}

D

简单来说,你首先把素数全部筛选出来,然后开始for素数,因为素数的数量少于n嘛,至少,大概在(logn)级别的。

然后你就可以枚举两个素数,然后再check第三个数是不是素数就好了。

#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; const int maxn = 10000; int np, pri[maxn+5], vis[maxn+5]; void prime_table(int n) { np = 0;
memset(vis, 0, sizeof(vis));
vis[0] = vis[1] = 1; for (int i = 2; i <= n; i++) {
if (vis[i])
continue; pri[np++] = i;
for (int j = i * i; j <= n; j += i)
vis[j] = 1;
}
} int main () {
int n;
prime_table(maxn);
while (scanf("%d", &n) == 1) {
int ans = 0;
for (int i = 0; i < np; i++) {
for (int j = i; j < np; j++) {
if (pri[i] + pri[j] >= n)
break;
int t = n - pri[i] - pri[j]; if (vis[t] == 0 && t >= pri[j])
ans++;
}
}
printf("%d\n", ans);
}
return 0;
}

E

原题 hdu 5106,最暴力的方法,就是强行数位dp莽过去就好了。

但是这道题,其实只需要枚举某个二进制数和R第一个1不同的位置就行了。因为如果R某个位置的1变成了0,那么以后01就随便取变成了组合数的问题。

#include<bits/stdc++.h>

using namespace std;
typedef long long LL;
#define MX 1005
#define MOD 1000000007 LL C[MX][MX], bit[MX];
int N;
char R[MX]; void init() {
int i, j;
bit[0] = 1LL;
for (i = 1; i < MX; i ++) {
bit[i] = 2 * bit[i - 1] % MOD;
}
C[0][0] = 1;
for (i = 1; i < MX; i ++) {
C[i][0] = C[i][i] = 1;
for (j = 1; j < i; j ++) {
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
}
}
} int main(){
init(); int Tcase, i, one;
while (scanf("%d %s", &N, R) == 2) {
int len = strlen(R);
int rlt = 0; long long B = 0;
for (i = 0; i < len && N >= 0; i ++) {
if (R[i] == '1') {
if (N <= len - i - 1) { if (N) rlt = (rlt + (long long) (bit[len - i - 1] - 1) * C[len - i - 2][N - 1] % MOD) % MOD;
rlt = (rlt + B * C[len - i - 1][N] % MOD) % MOD;
B += bit[len - i - 1];
B %= MOD;
N --;
}
}
}
if (rlt < 0) rlt += MOD;
printf("%d\n", rlt);
} }

喵哈哈村的魔法考试 Round #5 (Div.2) 题解的更多相关文章

  1. 喵哈哈村的魔法考试 Round #2 (Div.2) 题解

    喵哈哈村的魔法考试 Round #2 (Div.2) 题解 A.喵哈哈村的战争 题解: 这道题就是for一遍,统计每个村子的战斗力的和,然后统计哪个村子的战斗力和大一点就好了. 唯一的坑点,就是这道题 ...

  2. 喵哈哈村的魔法考试 Round #1 (Div.2) 题解

    喵哈哈村的魔法考试 Round #1 (Div.2) 题解 特别感谢出题人,qscqesze. 也特别感谢测题人Xiper和CS_LYJ1997. 没有他们的付出,就不会有这场比赛. A 喵哈哈村的魔 ...

  3. 喵哈哈村的魔法考试 Round #7 (Div.2) 题解

    喵哈哈村的魔法考试 Round #7 (Div.2) 注意!后四道题来自于周日的hihocoder offer收割赛第九场. 我建了个群:欢迎加入qscoj交流群,群号码:540667432 大概作为 ...

  4. 喵哈哈村的魔法考试 Round #1 (Div.2) 题解&源码(A.水+暴力,B.dp+栈)

    A.喵哈哈村的魔法石 发布时间: 2017年2月21日 20:05   最后更新: 2017年2月21日 20:06   时间限制: 1000ms   内存限制: 128M 描述 传说喵哈哈村有三种神 ...

  5. 喵哈哈村的魔法考试 Round #19 (Div.2) 题解

    题解: 喵哈哈村的魔力源泉(1) 题解:签到题. 代码: #include<bits/stdc++.h> using namespace std; int main(){ long lon ...

  6. 喵哈哈村的魔法考试 Round #14 (Div.2) 题解

    喵哈哈村的四月半活动(一) 题解: 唯一的case,就是两边长度一样的时候,第三边只有一种情况. #include <iostream> #include <cstdio> # ...

  7. 喵哈哈村的魔法考试 Round #4 (Div.2) 题解

    有任何疑问,可以加我QQ:475517977进行讨论. A 喵哈哈村的嘟嘟熊魔法(1) 题解 这道题我们只要倒着来做就可以了,因为交换杯子是可逆的,我们倒着去模拟一遍就好了. 有个函数叫做swap(a ...

  8. 喵哈哈村的魔法考试 Round #20 (Div.2) 题解

    题解: A 喵哈哈村的跳棋比赛 题解:其实我们要理解题意就好了,画画图看看这个题意.x<y,那么就交换:x>y,那么x=x%y. 如果我们经过很多次,或者y<=0了,那么就会无限循环 ...

  9. 喵哈哈村的魔法考试 Round #18 (Div.2) 题解

    喵哈哈村的古怪石碑(一) 题解:暴力check一下是等比数列还是等差数列,然后输出答案即可.注意如果数据范围是1e9的话,就要快速幂了. 代码: #include <cstdio> #in ...

  10. 喵哈哈村的魔法考试 Round #13 (Div.2) 题解

    喵哈哈村的木星传说(一) 旋转90°,找找规律就知道(x,y)->(n-1-y,x) 然后输出就好了. #include<bits/stdc++.h> using namespace ...

随机推荐

  1. Codeforces 923 C. Perfect Security

    http://codeforces.com/contest/923/problem/C Trie树 #include<cstdio> #include<iostream> us ...

  2. Your Prediction Gets As Good As Your Data

    Your Prediction Gets As Good As Your Data May 5, 2015 by Kazem In the past, we have seen software en ...

  3. 【转】详解linux vi命令用法

    功能最强在的编辑器--vi vi是所有UNIX系统都会提供的屏幕编辑器,它提供了一个视窗设备,通过它可以编辑文件.当然,对UNIX系统略有所知的人, 或多或少都觉得vi超级难用,但vi是最基本的编辑器 ...

  4. 在 Linux 中安装 VMware Tools

    由于较新的Linux版本中都包含了vm的部分组件,导致直接安装VMware Tools失败.所以这里写了篇新的. 软件版本:VMware 12 Linux版本:Ubuntu Desktop 16.04 ...

  5. 第14月第1天 uialterview 键盘 uibutton圆角

    1. 在IOS 8之后 当UIAlertView 和keyboard 同时出现时,会出现键盘闪现的情况 所以就修正UIAlertView http://blog.sina.com.cn/s/blog_ ...

  6. 2016最新的中国省市区三级数据库表.sql mssql

    /****** Object: Table [dbo].[t_Area] Script Date: 09/10/2016 09:35:46 ******/ SET ANSI_NULLS ON GO S ...

  7. git 修改已提交的注释

    在git中,其commit提供了一个--amend参数,可以修改最后一次提交的信息 修改最后一次提交注释 git commit --amend 然后在出来的编辑界面,直接编辑注释的信息,保存退出 gi ...

  8. mysql high availability 概述

    一.什么是高可用性 1.可用性是指服务不间断运转的时间,通常用百分比来表示,例如 99.999%表示每年最多允许5分钟的宕机时间 2.可用性的效果和开销比例呈线性增长 3.可用性的意义往往也不尽相同, ...

  9. linux内核环形缓冲区【转】

    转自:https://blog.csdn.net/eydwyz/article/details/56671023 循环缓冲区在一些竞争问题上提供了一种免锁的机制,免锁的前提是,生产者和消费 都只有一个 ...

  10. win7下iis中配置php.ini文件

    将php.ini-development配置文件重命名为php.ini配置文件即可. 接着做如下配置操作: 1.修改php.ini配置文件 打开php.ini配置文件,找到 12 ; On windo ...