class Solution { public: /* * @param a: The first integer * @param b: The second integer * @return: The sum of a and b */ int aplusb(int a, int b) { // write your code here, try to do it without arithmetic operators. )return b; )return a; int x1 = a^…
Median String time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given two strings ss and tt, both consisting of exactly kk lowercase Latin letters, ss is lexicographically less than …
A + B ProblemII Time Limit: 2000/1000 MS(Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 317773 Accepted Submission(s):61748 Problem Description I have a verysimple problem for you. Given two integers A and B, your j…
题意:给你两个字符串\(s\)和\(t\),保证\(t\)的字典序大于\(s\),求他们字典序中间的字符串. 题解:我们假设题目给的不是字符串,而是两个10禁止的正整数,那么输出他们之间的数只要把他两加起来除\(2\)就行了,那么对于字符串又为何不可呢?我们可以将每个字母看成\(26\)进制的数,像高精度那样模拟加法运算的过程,然后再模拟除\(2\)的过程即可. 代码: int k; string s,t; int c[N]; int d[N]; int main() { ios::sync_w…
Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 算法:模拟加法过程 class Solution { public: string addBinary(string a, string b) { int len1=a.size(); int len2=b.size(); ; rev…
[题目] 输入数字n,按顺序输出从1最大的n位10进制数.比如输入3,则输出1.2.3一直到最大的3位数即999. [分析] 这是一道很有意思的题目.看起来很简单,其实里面却有不少的玄机. [常规思路] 应聘者在解决这个问题的时候,最容易想到的方法是先求出最大的n位数是什么,然后用一个循环从1开始逐个输出.很快,我们就能写出如下代码: C++ Code 1234567891011121314 // Print numbers from 1 to the maximum number wi…
题目链接: Problem B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description 度熊面前有一个全是由1构成的字符串,被称为全1序列.你可以合并任意相邻的两个1,从而形成一个新的序列.对于给定的一个全1序列,请计算根据以上方法,可以构成多少种不同的序列. Input 这里包括多组测试数据,每组测试数据包含一个正整数N,代表…
A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 315214 Accepted Submission(s): 61139 Problem Description I have a very simple problem for you. Given two integers A and B, you…
今天看不进去论文,也学不进去新技术,于是先把题刷了,一会补别的. -----------------------------------------------------我才不是分割线------------------------------------------------- Add Two Numbers You are given two linked lists representing two non-negative numbers. The digits are stored…
作者:何海涛 出处:http://zhedahht.blog.163.com/ 题目:输入数字n,按顺序输出从1最大的n位10进制数.比如输入3,则输出1.2.3一直到最大的3位数即999. 分析:这是一道很有意思的题目.看起来很简单,其实里面却有不少的玄机. 应聘者在解决这个问题的时候,最容易想到的方法是先求出最大的n位数是什么,然后用一个循环从1开始逐个输出.很快,我们就能写出如下代码: // Print numbers from 1 to the maximum number with n…