太菜了啊,一不小心就goodbye rating了

A. New Year and Counting Cards
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Your friend has n cards.

You know that each card has a lowercase English letter on one side and a digit on the other.

Currently, your friend has laid out the cards on a table so only one side of each card is visible.

You would like to know if the following statement is true for cards that your friend owns: "If a card has a vowel on one side, then it has an even digit on the other side." More specifically, a vowel is one of 'a', 'e', 'i', 'o' or 'u', and even digit is one of '0', '2', '4', '6' or '8'.

For example, if a card has 'a' on one side, and '6' on the other side, then this statement is true for it. Also, the statement is true, for example, for a card with 'b' and '4', and for a card with 'b' and '3' (since the letter is not a vowel). The statement is false, for example, for card with 'e' and '5'. You are interested if the statement is true for all cards. In particular, if no card has a vowel, the statement is true.

To determine this, you can flip over some cards to reveal the other side. You would like to know what is the minimum number of cards you need to flip in the worst case in order to verify that the statement is true.

Input

The first and only line of input will contain a string s (1 ≤ |s| ≤ 50), denoting the sides of the cards that you can see on the table currently. Each character of s is either a lowercase English letter or a digit.

Output

Print a single integer, the minimum number of cards you must turn over to verify your claim.

Examples
input
ee

output
2

input
z

output
0

input
0ay1

output
2

Note

In the first sample, we must turn over both cards. Note that even though both cards have the same letter, they could possibly have different numbers on the other side.

In the second sample, we don't need to turn over any cards. The statement is vacuously true, since you know your friend has no cards with a vowel on them.

In the third sample, we need to flip the second and fourth cards.

原谅我英语不好,看懂了就是统计元音和奇数个数

#include<bits/stdc++.h>
using namespace std;
string c="aeiou13579";
int main()
{string s;cin>>s;int ans=0;for(int i=0;s[i];i++)for(int j=0;c[j];j++)if(s[i]==c[j])ans++;cout<<ans;return 0;
}

B. New Year and Buggy Bot
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Bob programmed a robot to navigate through a 2d maze.

The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'.

There is a single robot in the maze. It's start position is denoted with the character 'S'. This position has no obstacle in it. There is also a single exit in the maze. It's position is denoted with the character 'E'. This position has no obstacle in it.

The robot can only move up, left, right, or down.

When Bob programmed the robot, he wrote down a string of digits consisting of the digits 0 to 3, inclusive. He intended for each digit to correspond to a distinct direction, and the robot would follow the directions in order to reach the exit. Unfortunately, he forgot to actually assign the directions to digits.

The robot will choose some random mapping of digits to distinct directions. The robot will map distinct digits to distinct directions. The robot will then follow the instructions according to the given string in order and chosen mapping. If an instruction would lead the robot to go off the edge of the maze or hit an obstacle, the robot will crash and break down. If the robot reaches the exit at any point, then the robot will stop following any further instructions.

Bob is having trouble debugging his robot, so he would like to determine the number of mappings of digits to directions that would lead the robot to the exit.

Input

The first line of input will contain two integers n and m (2 ≤ n, m ≤ 50), denoting the dimensions of the maze.

The next n lines will contain exactly m characters each, denoting the maze.

Each character of the maze will be '.', '#', 'S', or 'E'.

There will be exactly one 'S' and exactly one 'E' in the maze.

The last line will contain a single string s (1 ≤ |s| ≤ 100) — the instructions given to the robot. Each character of s is a digit from 0 to 3.

Output

Print a single integer, the number of mappings of digits to directions that will lead the robot to the exit.

Examples
input
5 6.....#S....#.#.....#.......E..333300012

output
1

input
6 6..............SE....................01232123212302123021

output
14

input
5 3....S.###.E....3

output
0

Note

For the first sample, the only valid mapping is , where D is down, L is left, U is up, R is right.

全排列24种情况啊,等等为毛我写的只有23种,挂了两个题果断GG(do,while都不懂的我果断GG啊,但是我感觉思路很简洁啊,就是让1 2 3 4分别去代表U D L R,然后我a[0]代表上,a[1]代表下,a[2]代表左,a[3]代表右

#include<bits/stdc++.h>
using namespace std;
string s[51];
int a[6],sx,sy;
int main()
{int n,m;cin>>n>>m;for(int i=0;i<n;i++)cin>>s[i];for(int i=0;i<n;i++)for(int j=0;j<m;j++)if(s[i][j]=='S')sx=i,sy=j;string c;cin>>c;for(int i=0;i<4;i++)a[i]=i+48;int ans=0;do{int f=0;int tx=sx,ty=sy;for(int i=0;c[i];i++){if(c[i]==a[0])tx-=1;else if(c[i]==a[1])tx+=1;else if(c[i]==a[2])ty-=1;else ty+=1;if(tx<0||ty<0||tx>=n||ty>=m)break;if(s[tx][ty]=='#')break;if(s[tx][ty]=='E'){f=1;break;}}ans+=f;}while(next_permutation(a,a+4));cout<<ans;return 0;
}

C. New Year and Curling
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Carol is currently curling.

She has n disks each with radius r on the 2D plane.

Initially she has all these disks above the line y = 10100.

She then will slide the disks towards the line y = 0 one by one in order from 1 to n.

When she slides the i-th disk, she will place its center at the point (xi, 10100). She will then push it so the disk’s ycoordinate continuously decreases, and x coordinate stays constant. The disk stops once it touches the line y = 0or it touches any previous disk. Note that once a disk stops moving, it will not move again, even if hit by another disk.

Compute the y-coordinates of centers of all the disks after all disks have been pushed.

Input

The first line will contain two integers n and r (1 ≤ n, r ≤ 1 000), the number of disks, and the radius of the disks, respectively.

The next line will contain n integers x1, x2, ..., xn (1 ≤ xi ≤ 1 000) — the x-coordinates of the disks.

Output

Print a single line with n numbers. The i-th number denotes the y-coordinate of the center of the i-th disk. The output will be accepted if it has absolute or relative error at most 10 - 6.

Namely, let's assume that your answer for a particular value of a coordinate is a and the answer of the jury is b. The checker program will consider your answer correct if  for all coordinates.

Example
input
6 25 5 6 8 3 12

output
2 6.0 9.87298334621 13.3370849613 12.5187346573 13.3370849613

Note

The final positions of the disks will look as follows:

In particular, note the position of the last disk.

C我逃了开根为负的情况,但是也不会是0啊,最起码是r

#include<bits/stdc++.h>
using namespace std;
int x[1005];
double y[1008];
int main()
{int n,r;cin>>n>>r;for(int i=0;i<n;i++)cin>>x[i];for(int i=0;i<n;i++){y[i]=r;for(int j=0;j<i;j++)if(fabs(x[j]-x[i])<=2.*r)y[i]=max(y[i],y[j]+sqrt(4*r*r-(x[i]-x[j])*(x[i]-x[j])));}for(int i=0;i<n;i++)printf("%.12f ",y[i]);return 0;
}

D. New Year and Arbitrary Arrangement
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given three integers kpa and pb.

You will construct a sequence with the following algorithm: Initially, start with the empty sequence. Each second, you do the following. With probability pa / (pa + pb), add 'a' to the end of the sequence. Otherwise (with probability pb / (pa + pb)), add 'b' to the end of the sequence.

You stop once there are at least k subsequences that form 'ab'. Determine the expected number of times 'ab' is a subsequence in the resulting sequence. It can be shown that this can be represented by P / Q, where P and Q are coprime integers, and . Print the value of .

Input

The first line will contain three integers integer k, pa, pb (1 ≤ k ≤ 1 000, 1 ≤ pa, pb ≤ 1 000 000).

Output

Print a single integer, the answer to the problem.

Examples
input
1 1 1

output
2

input
3 1 4

output
370000006

Note

The first sample, we will keep appending to our sequence until we get the subsequence 'ab' at least once. For instance, we get the sequence 'ab' with probability 1/4, 'bbab' with probability 1/16, and 'aab' with probability 1/8. Note, it's impossible for us to end with a sequence like 'aabab', since we would have stopped our algorithm once we had the prefix 'aab'.

The expected amount of times that 'ab' will occur across all valid sequences is 2.

For the second sample, the answer is equal to .

#include<bits/stdc++.h>
using namespace std;
const int MD=1e9+7,N=2005;
int dp[N][N];
int po(int a,int x)
{int ans=1;while(x){if(x&1) ans=1LL*ans*a%MD;a=1LL*a*a%MD;x>>=1;}return ans;
}
int main()
{int k,a,b,ta,tb,ans=0;scanf("%d%d%d",&k,&a,&b);ta=1LL*a*po(a+b,MD-2)%MD;tb=MD-ta+1;dp[1][0]=1;for(int i=1; i<=k; i++)for(int j=0; j<k-i; j++){dp[i+1][j]=(dp[i+1][j]+1LL*dp[i][j]*ta%MD)%MD;if(j+i+i>=k)ans=(ans+1LL*dp[i][j]*tb%MD*(j+i+i-k)%MD)%MD;else dp[i][j+i]=(dp[i][j+i]+1LL*dp[i][j]*tb%MD)%MD;}ans=(ans+k+1LL*a*po(b,MD-2)%MD)%MD;printf("%d\n",ans);
}

转载于:https://www.cnblogs.com/BobHuang/p/8148972.html

Good Bye 2017相关推荐

  1. Good Bye 2017 G. New Year and Original Order 数位dp + 按数贡献

    传送门 文章目录 题意: 思路: 题意: 定义S(k)S(k)S(k)为将kkk的每一位拿出来从小到大排序后构成的数,比如S(3421)=1234S(3421)=1234S(3421)=1234,求S ...

  2. mysql安装文件瘦身_MySQL瘦身

    转:PCL+VS2010环境配置 1.下载 http://www.pointclouds.org/downloads/windows.html出下载PCL完全安装包1.6.0 all-in-one-i ...

  3. 2018创投圈风云再起,企服征途百家争鸣,寻找中国创业最强音!

    2018.01.24 过去一年 共享单车战场风云变幻 新零售赛道硝烟四起 巨头纷纷入局 人工智能领域争夺愈发激烈 新风口呼啸 新赛道疾驰 企服征途 百家争鸣 谁能问鼎中国创业好声音擂台? 1月24日 ...

  4. C++正则表达式(regex_match、regex_search与regex_replace)

    前言 1 转义字符 2 regex_match 2.1 基本概念 2.2 匹配结果 2.3 实例 3 regex_search 3.1 基本概念 3.2 实例 4 regex_replace 4.1 ...

  5. 团体程序设计天梯赛真题(部分题解,持续更新)

    文章目录 天梯赛真题 L1-008 求整数段和(10分) 输入格式: 输出格式: 输入样例: 输出样例: 解题过程: L1-018 大笨钟(10分) 输入格式: 输出格式: 输入样例1: 输出样例1: ...

  6. 伪代码 java_java伪代码

    愚公移山的目标是毕力平险,指通豫南,达于汉阴,方法是扣石垦壤,箕畚运于渤海之尾 条件判断if(愚公死了)我的儿子替我完成.循环结构是"子又生孙,孙又生子,子子孙孙无穷匮也" imp ...

  7. 面试遇到的 python 问题 -- 2017年 手写代码

    1.二维数组中的查找 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数. # -*- ...

  8. 机器学习2017,导言(李宏毅

    李宏毅<机器学习>_哔哩哔哩_bilibili 2021偏向深度学习,相对前沿一点的知识:2017偏向机器学习,经典的知识 从今年开始(2017年),人工智慧这个词突然变得非常非常非常的热 ...

  9. Bye, 2018; Hi, 2019

    虽然我还时时的沉浸在2018的日历里,但时光已毫不留情的将2018年留在了记忆里.2019,相见恨早. 距离2014年底已经有了4个年头加2个月的时间了.回首这4年,从PHP+SQL到TP,从共享文件 ...

最新文章

  1. 图解 SQL 中 JOIN 的各种用法
  2. Windows程序设计之创建窗口示例
  3. K Co-prime Permutation 构造,gcd,互质(2020.12.南京)
  4. 如何给python升级_python升级后,如何给virtualenv里的python进行升级
  5. 做三维模型_这几款倾斜实景三维裸眼3D采集软件你了解吗?
  6. Windows部署KMS服务器
  7. 虚拟机+linux(NeoKylin)网络配置问题:UDP广播不能发送接收数据问题系列解决
  8. ExtJs4(3)——带搜索和操作按钮的表
  9. 微信公众号服务器需要备案,微擎不备案可以用吗?微信公众号开发域名一定要备案吗?...
  10. 关于Excel操作编写的一个软件设计构思案例[连载]
  11. iqos烟弹哪个最好抽?我品尝了十一种电子烟烟弹后告诉你
  12. 关于CS找实习的不完整经验
  13. java基础知识面试题(41-95)
  14. APS生产计划排程系统介绍-FLEXSCHE-真正解决复杂需求的灵活且强大的通用系统
  15. GBASE 8a MPP EXplain extended
  16. 乐优商城之规格参数商品查询(十)
  17. 循环世界模型(Recurrent World Models)——真实世界建模的强化学习利器
  18. XAG聚合细节举例说明
  19. cefsharp winform 支持视频播放
  20. LUNA16数据集的百度云链接

热门文章

  1. 【SpringBoot】解决拦截器注入 Service 为空问题
  2. c++内存优化:二级间接索引模式内存池
  3. 我再也不-或许永远不-用zend studio-受够了!
  4. CATransition 动画
  5. MYSQL-统计查询
  6. Audio strage 声音相关
  7. 自动化测试框架搭建三python环境安装selenium和手动下载安装selenium的方法
  8. 手把手教你写网站:Python WEB开发技术实战
  9. 如何让产品用户拥有一流的上传体验
  10. 从零开始山寨Caffe·叁:全局线程管理器