A. Fake NP

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.

You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times.

Solve the problem to show that it's not a NP problem.

Input

The first line contains two integers l and r (2 ≤ l ≤ r ≤ 109).

Output

Print single integer, the integer that appears maximum number of times in the divisors.

If there are multiple answers, print any of them.

Examples
Input
19 29
Output
2
Input
3 6
Output
3
Note

Definition of a divisor: https://www.mathsisfun.com/definitions/divisor-of-an-integer-.html

The first example: from 19 to 29 these numbers are divisible by 2: {20, 22, 24, 26, 28}.

The second example: from 3 to 6 these numbers are divisible by 3: {3, 6}.

题目链接:http://codeforces.com/contest/805/problem/A

分析:直接判断l==r就输出l,否则输出2就可以了!

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int l,r;
scanf("%d%d",&l,&r);
if(l==r)
cout<<l<<endl;
else cout<<<<endl;
return ;
}

B. 3-palindrome

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick.

He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', with no palindromes of length 3 appearing in the string as a substring. For example, the strings "abc" and "abca" suit him, while the string "aba" doesn't. He also want the number of letters 'c' in his string to be as little as possible.

Input

The first line contains single integer n (1 ≤ n ≤ 2·105) — the length of the string.

Output

Print the string that satisfies all the constraints.

If there are multiple answers, print any of them.

Examples
Input
2
Output
aa
Input
3
Output
bba
Note

A palindrome is a sequence of characters which reads the same backward and forward.

题目链接:http://codeforces.com/contest/805/problem/B

分析:直接输出aabb.........这组样例即可,要多少个输出多少个,比如n=5 ,aabba,n=6,aabbaa。。。。。。

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=;i<=n;++i)
{
cout<<"a";
++i;
if(i<=n)
cout<<"a";
++i;
if(i<=n)
cout<<"b";
++i;
if(i<=n)
cout<<"b";
}
cout<<endl;
}
return ;
}

C. Find Amir

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.

There are n schools numerated from 1 to n. One can travel between each pair of them, to do so, he needs to buy a ticket. The ticker between schools i and j costs and can be used multiple times. Help Sajjad to find the minimum cost he needs to pay for tickets to visit all schools. He can start and finish in any school.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of schools.

Output

Print single integer: the minimum cost of tickets needed to visit all schools.

Examples
Input
2
Output
0
Input
10
Output
4
Note

In the first example we can buy a ticket between the schools that costs .

题目链接:http://codeforces.com/contest/805/problem/C

分析: 就解释一下第二组数据怎么来的,即为答案!

1->10 ,10->2, 2->9, 9->3, 3->8  ,8->4,4->7,7->5,5->6

(1+10)%11==0;

(10+2)%11==1 ;

(2+9) %11==0;

(9+3)%11==1;

(3+8)%11==0;

(8+4)%11==1;

(4+7)%11==0;

(7+5)%11==1;

(5+6)%11==0;

上式求和sum即为4.。。。。。遍历一遍求值,即可

在探索的过程中,似乎发现了一个公式:sum=(n-1)/2;

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int sum=n-;
sum/=;
printf("%d\n",sum);
}
return ;
}

D. Minimum number of steps

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum number of steps we should perform to make our job done modulo 109 + 7.

The string "ab" appears as a substring if there is a letter 'b' right after the letter 'a' somewhere in the string.

Input

The first line contains the initial string consisting of letters 'a' and 'b' only with length from 1 to 106.

Output

Print the minimum number of steps modulo 109 + 7.

Examples
Input
ab
Output
1
Input
aab
Output
3
Note

The first example: "ab"  →  "bba".

The second example: "aab"  →  "abba"  →  "bbaba"  →  "bbbbaa".

题目链接:http://codeforces.com/contest/805/problem/D

分析:用t去记录b得数量,遇到'b',t++,遇到'a'应该是先加上答案t的值,然后t的值再翻倍!

例如:

aab   遇到a变成 abba  遇到a变成bbbbaa  b都是翻倍的增加的

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
const int N=1e9+;
int main()
{
string s;
cin>>s;
int ans=;
int t=;//b的数量
for(int i=s.length()-;i>=;i--)
{
if(s[i]=='b')
t=(t+)%N;
else
{
ans=(ans+t)%N;
t=(t*)%N;
}
}
cout<<ans<<endl;
return ;
}

Codeforces Round #411 (Div. 2)(A,B,C,D 四水题)的更多相关文章

  1. Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  2. Codeforces Round #373 (Div. 2) C. Efim and Strange Grade 水题

    C. Efim and Strange Grade 题目连接: http://codeforces.com/contest/719/problem/C Description Efim just re ...

  3. Codeforces Round #185 (Div. 2) A. Whose sentence is it? 水题

    A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  4. Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 水题

    A. Vitya in the Countryside 题目连接: http://codeforces.com/contest/719/problem/A Description Every summ ...

  5. Codeforces Round #371 (Div. 2) A. Meeting of Old Friends 水题

    A. Meeting of Old Friends 题目连接: http://codeforces.com/contest/714/problem/A Description Today an out ...

  6. Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题

    B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...

  7. Codeforces Round #310 (Div. 2) B. Case of Fake Numbers 水题

    B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  8. Codeforces Round #309 (Div. 2) B. Ohana Cleans Up 字符串水题

    B. Ohana Cleans Up Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/pr ...

  9. Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks 字符串水题

    A. Kyoya and Photobooks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

随机推荐

  1. 解决IOS iframe不滚动问题

    .frameBox{ position: fixed; top: 0; left: 0; right: 0; bottom: 0; -webkit-overflow-scrolling: touch; ...

  2. APP Store开发指南

    App Store 审核指南 iOS App打包上架超详细流程 ---2017.03 苹果对开发者提交的应用的审核之严格是出了名的,了解苹果的审核标准对于开发者防止应用被拒有着十分重要的意义.几天前苹 ...

  3. qt关键字高亮

    qt的高亮显示主要是使用qsyntaxhighlighter类,由于qsyntaxhighlighter是抽象基类,所以需要继承并自己实现 //头文件 #ifndef MARKDOWN_HIGHLIG ...

  4. 基于 HTML5 WebGL 的 3D 场景中的灯光效果

    构建 3D 的场景除了创建模型,对模型设置颜色和贴图外,还需要有灯光的效果才能更逼真的反映真实世界的场景.这个例子我觉得既美观又代表性很强,所以拿出来给大家分享一下. 本例地址:http://www. ...

  5. SpringMVC对包的扫描范围扩大后,导致的事务配置不生效问题

    问题场景 项目使用的框架:Spring 4.1.4 + Hibernate 4.3.8 + MySQL. web.xml中对Spring的配置: <!-- 把 Spring 容器集成到 Web ...

  6. java-FFmpeg(一) 实现视频的转码和截图功能

    FFmpeg是一个开源免费跨平台的视频和音频流方案,属于自由软件,采用LGPL或GPL许可证(依据你选择的组件).它提供了录制.转换以及流化音视频的完整解决方案.它包含了非常先进的音频/视频编解码库l ...

  7. centos7 部署 ELK 日志系统

    =============================================== 2017/12/24_第3次修改                       ccb_warlock 更 ...

  8. ASP.NET Core 一步步搭建个人网站(4)_主页和登录验证

    上章节我们已经定制好动态配置的菜单,用户登录网站的第一步就是进入首页内容,那我们先搭建一下我们的首页内容.想着自己的网站内容主要是个人博客类型,所以,首页就展示博主本人的一些基本信息吧,哈哈.当然,做 ...

  9. [编织消息框架][JAVA核心技术]动态代理应用3

    我们先使用懒处理实现提取接口类上的元信息: public abstract class QRpcFactory { public static <T> T loadProxy(Class& ...

  10. thinkphp 3.1.3 redis 只能读取 无法写入的问题

    找到thinkphp的目录 thinkphp\Extend\Driver\Cache    下面的Redis    大概在81行足有 // if(is_int($expire)) { // redis ...