凉肝的比赛题解

A - Mezo Playing Zoma

Today, Mezo is playing a game. Zoma, a character in that game, is initially at position x=0x=0. Mezo starts sending nn commands to Zoma. There are two possible commands:

  • ‘L’ (Left) sets the position x:=x−1;
  • ‘R’ (Right) sets the position x:=x+1.

Unfortunately, Mezo’s controller malfunctions sometimes. Some commands are sent successfully and some are ignored. If the command is ignored then the position xx doesn’t change and Mezo simply proceeds to the next command.
For example, if Mezo sends commands “LRLR”, then here are some possible outcomes (underlined commands are sent successfully):

  • “LRLR” — Zoma moves to the left, to the right, to the left again and to the right for the final time,ending up at position 0;
  • “LRLR” — Zoma recieves no commands, doesn’t move at all and ends up at position 0 as well;
  • “LRLR” — Zoma moves to the left, then to the left again and ends up inposition -2.
    Mezo doesn’t know which commands will be sent successfully beforehand. Thus, he wants to know how many different positions may Zoma end up at.
    Input
    The first line contains nn (1≤n≤105)(1≤n≤105) — the number of commands Mezo sends.The second line contains a string ss of nn commands, each either ‘L’ (Left) or ‘R’ (Right).
    Output
    Print one integer — the number of different positions Zoma may end up at.
    Example
    Input
    4
    LRLR
    Output
    5
    Note
    In the example, Zoma may end up anywhere between −2 and 2.
    理解:

输入n个字母,只包括‘L’ ‘R’,分别表示向左和向右。每个字母都有可能有作用,也可能没作用,故最后至多有n+1个新位置(加上原来零点的位置。

#include<cstdio>
using namespace std;
int main()
{
	int n;
	char a[100010];
	cin>>n;
	cin>>a;
	printf("%d",n+1);
	return 0;
 } 

C - Fadi and LCM

Today, Osama gave Fadi an integer X, and Fadi was wondering about the minimum possible value of max(a,b) such that LCM(a,b) equals X. Both a and b should be positive integers.
LCM(a,b) is the smallest positive integer that is divisible by both a and b. For example, LCM(6,8)=24, LCM(4,12)=12, LCM(2,3)=6.
Of course, Fadi immediately knew the answer. Can you be just like Fadi and find any such pair?
Input
The first and only line contains an integer X (1≤X≤10^12).
Output
Print two positive integers, aa and bb, such that the value of max(a,b) is minimum possible and LCM(a,b) equals X. If there are several possible such pairs, you can print any.
Examples
Input

2
Output
1 2
Input
6
Output
2 3
Input
4
Output
1 4
Input
1
Output
1 1
理解:

#include<cstdio>
#include<iostream>
#include<cmath>
typedef long long ll;
using namespace std;
ll gcd(ll a,ll b)
{
	if(a%b==0)
    	return b;
    else;
        return gcd(b,a%b);
}
int main()
{
	ll n;
	cin>>n;
	ll a=1,b=n;
	for(ll i=1;i<sqrt(n);i++)
	{
		if(n%i==0)
		{
			b=n/i;
			ll x=gcd(b,i);
			if(x==1)
			{
				a=i;
				continue;
			}
		}
	}
	cout<<a<<" "<<n/a;
	return 0;
}

E - Deadline

在这里插入图片描述
Input
The first line contains a single integer T (1≤T≤50) — the number of test cases.The next TT lines contain test cases – one per line. Each line contains two integers nn and dd (1≤n≤1e9, 1≤d≤1e9 ) — the number of days before the deadline and the number of days the program runs.
Output
Print TT answers — one per test case. For each test case print YES (case insensitive) if Adilbek can fit in nn days or NO (case insensitive) otherwise.
Example
Input

3
1 1
4 5
5 11
Output
YES
YES
NO
在这里插入图片描述题解:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int a,b,flag=0;
		cin>>a>>b;
		if(a>=b)
		{
			printf("YES\n");
			continue;
		}
		int k=(a-1)/2;
		if(b%(k+1)==0)
		{
			if((k+b/(k+1))<=a)
				printf("YES\n");
			else
				printf("NO\n");
		}
		else
		{
			if((k+1+b/(k+1))<=a)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}

F - Yet Another Meme Problem

Try guessing the statement from this picture http://tiny.cc/ogyoiz.
You are given two integers A and B, calculate the number of pairs (a,b) such that 1≤a≤A, 1≤b≤B, and the equation a⋅b+a+b=conc(a,b) is true; conc(a,b) is the concatenation of a and b (for example, conc(12,23)=1223, conc(100,11)=10011). a and b should not contain leading zeroes.
Input
The first line contains t (1≤t≤100) — the number of test cases.Each test case contains two integers A and B (1≤A,B≤109).
Output
Print one integer — the number of pairs (a,b) such that 1≤a≤A 1≤a≤A, and the equation a⋅b+a+b=conc(a,b) is true.
Example
Input

3
1 11
4 2
191 31415926
Output
1
0
1337
Note
There is only one suitable pair in the first test case: a=1, b=9 (1+9+1⋅9=19).
理解:

求有多少对(a,b)符合a⋅b+a+b=conc(a,b),1≤a≤A, 1≤b≤B,conc(a,b)=a10^n+b.(n为b的位数)
a⋅b+a+b=conc(a,b),则a⋅b+a+b=a
10^n+b.(n为b的位数)
a⋅b+a=a10^n 则a(1+b)=a*10^n
b+1=10^n,只需要求出来在小于B范围内有多少符合这个条件的,再与A相乘即可。

#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		unsigned int A,B;//不能时int型 因为规定大于零(黑脸
		cin>>A>>B;
		ll k=B,count=0,n=1;
		while(k)
		{
			k=k/10;
			count++;
			n*=10;
		}//求出来B的位数
		if((B+1)==n)//该数是否符合b+1=10^n,即最高位上的所以数是否有符合b+1=10^n的。
			cout<<count*A<<endl;
		else
			cout<<(count-1)*A<<endl;
	}
	return 0;
 } 

G - HQ9+

HQ9+ is a joke programming language which has only four one-character instructions:
“H” prints “Hello, World!”,
“Q” prints the source code of the program itself,
“9” prints the lyrics of “99 Bottles of Beer” song,
“+” increments the value stored in the internal accumulator.
Instructions “H” and “Q” are case-sensitive and must be uppercase. The characters of the program which are not instructions are ignored.
You are given a program written in HQ9+. You have to figure out whether executing this program will produce any output.
Input
The input will consist of a single line p which will give a program in HQ9+. String p will contain between 1 and 100 characters, inclusive. ASCII-code of each character of p will be between 33 (exclamation mark) and 126 (tilde), inclusive.
Output
Output “YES”, if executing the program will produce any output, and “NO” otherwise.
Examples
Input

Hi!
Output
YES
Input
Codeforces
Output
NO
Note
In the first case the program contains only one instruction — “H”, which prints “Hello, World!”.In the second case none of the program characters are language instructions.
理解:

当输入的字符型中有’H’‘Q’'9’字符时,则有各自的输出,否则没有输出。

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char a[1000];
	cin>>a;
	int n=strlen(a);
	for(int i=0;i<n;i++)
	{
		if(a[i]!='H'&&a[i]!='Q'&&a[i]!='9')
			continue;
		else 
		{	
			printf("YES");
			return 0;
		}
	}
	printf("NO");
	return 0;
 } 
购物商城项目采用PHP+mysql有以及html+css jq以及layer.js datatables bootstorap等插件等开发,采用了MVC模式,建立一个完善的电商系统,通过不同用户的不同需求,进行相应的调配和处理,提高对购买用户进行配置….zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值