博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
这几天刷CF水题感觉还好的几道题~
阅读量:4299 次
发布时间:2019-05-27

本文共 5893 字,大约阅读时间需要 19 分钟。

B. Queue at the School
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward each second.

Let's describe the process more precisely. Let's say that the positions in the queue are sequentially numbered by integers from 1 to n, at that the person in the position number 1 is served first. Then, if at time x a boy stands on the i-th position and a girl stands on the (i + 1)-th position, then at time x + 1 the i-th position will have a girl and the (i + 1)-th position will have a boy. The time is given in seconds.

You've got the initial position of the children, at the initial moment of time. Determine the way the queue is going to look after t seconds.

Input

The first line contains two integers n and t (1 ≤ n, t ≤ 50), which represent the number of children in the queue and the time after which the queue will transform into the arrangement you need to find.

The next line contains string s, which represents the schoolchildren's initial arrangement. If the i-th position in the queue contains a boy, then the i-th character of string s equals "B", otherwise the i-th character equals "G".

Output

Print string a, which describes the arrangement after t seconds. If the i-th position has a boy after the needed time, then the i-th character a must equal "B", otherwise it must equal "G".

Sample test(s)
input
5 1BGGBG
output
GBGGB
input
5 2BGGBG
output
GGBGB
input
4 1GGGB
output
GGGB
 
 
题目的大意是给你一堆汉子妹子然后给定一个时间然后在这个时间内,如果汉子在妹子前面,汉子就得跟妹子换位置这道题首先得注意可以换位置的时间因为这关乎汉子能最后换到哪里去的问题接下来再搜索需要换位子的汉子,然后换成功一次后就得跳过该人 进入下一个人的判断 代码如下 #include
#include
using namespace std;int main(){ int n,t; cin>>n>>t; char str[105]; char s; cin>>str; int i,j; for(j=0;j
 
 
 
 
 
A. Lucky Division     
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
Input
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
Output
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
Sample test(s)
input
47
output
YES
input
16
output
YES
input
78
output
NO
Note
Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
唔这道题的大意是让你搜索一个范围的的接近幸运数,我们把只含4或7的数称之为幸运数,而接近幸运数指的一个能被幸运数整除的数字是故范围更大,这道题是纯暴力做法因为给定的范围很小,所以我很偷懒的直接把这个范围内的幸运数枚举了出来然后再将输入的数依次跟幸运数去取余如果等于0这个数就是接近幸运数,当然如果给定的范围很大则用循环找出这个大范围内的所有幸运数并存在数组里然后再用N去对这个数组里的数依次取余只要有一个为0那就是接近幸运数了 代码如下~
#include
using namespace std;int main(){ int n,m,t=0,c=0,a; cin>>n; {if(n%4==0||n%7==0||n%44==0||n%77==0||n%74==0||n%47==0||n%444==0||n%447==0||n%474==0||n%477==0||n%744==0||n%747==0||n%774==0||n%777==0) cout<<"YES"<
using namespace std;int main(){ int i,n,a[100000],b[100000],u=0; cin>>n; for(i=0;i
>a[i]>>b[i]; } for(i=0;i
#include
#include
#include
using namespace std;int main(){ char a[1005],b[1005],c[1005]; int len1,len2,len3; int i; cin>>a>>b>>c; len1=strlen(a); len2=strlen(b); len3=strlen(c); strcat(a,b); sort(a,a+len1+len2); sort(c,c+len3); if(strcmp(a,c)==0) cout<<"YES"<
Note

Consider the first test sample. Manao can fail his first push and push the wrong button. In this case he will already be able to guess the right one with his second push. And his third push will push the second right button. Thus, in the worst-case scenario he will only need 3 pushes.

 
这道题是一道简单的数学题,一开始把它理解为错排了后来认真看了一下发现与错排还是有区别的 大意是给你一串密码 然后问你最悲催的得按多少下那个键盘你才能过 注意每按错一个密码就得重新开始 而且还是一个一个的按。 唔这道题的数据是有规律的首先1对应1 2对应3 3对应7 我自己再模拟了4 5 6 分别为14 25 41乍看之下木有规律 但是不难发现 无论如何最后一次都是对的 都得按那最后一个正确的密码 所以可以把每个数先减去1 得到0 2 6 13 24 40 唔 这有啥规律呢 后一个减去前一个试试看呗 不难发现 出现了2 4 7 11 16 这些数 再减一次发现为2 3 4 5 成为了一个等差数列 是故如果把0 2 6 13 24 这些数设为a[i]那么a[i]-a[i-1](i从1开始)的差就是一个首项为2 公差为1的前N项数列的和的通项公式为(i*i+i)/2+1, 最后递归得到a[n-1]再加上1就是答案了 代码如下 #include
using namespace std;int main(){ int a[100005]; int n; cin>>n; a[0]=0; a[1]=2; int i; for(i=1;i
 

转载地址:http://uupws.baihongyu.com/

你可能感兴趣的文章
phpstorm开发工具的设置用法
查看>>
Linux 系统挂载数据盘
查看>>
Git基础(三)--常见错误及解决方案
查看>>
Git(四) - 分支管理
查看>>
PHP Curl发送数据
查看>>
HTTP协议
查看>>
HTTPS
查看>>
git add . git add -u git add -A区别
查看>>
apache下虚拟域名配置
查看>>
session和cookie区别与联系
查看>>
PHP 实现笛卡尔积
查看>>
Laravel中的$loop
查看>>
CentOS7 重置root密码
查看>>
Centos安装Python3
查看>>
PHP批量插入
查看>>
laravel连接sql server 2008
查看>>
Laravel 操作redis的各种数据类型
查看>>
Laravel框架学习笔记之任务调度(定时任务)
查看>>
laravel 定时任务秒级执行
查看>>
浅析 Laravel 官方文档推荐的 Nginx 配置
查看>>