第七題:
主要格式控制
**
第八題#include
#include
#include
using
namespace std;
int a, b;
char c;
intmain()
思路:
列舉所有的情況,如果當前這個序列是回文,就ans++, 最後輸出ans
**
第九題#include
#include
#include
using
namespace std;
string x, s;
intmain()
}}cout
}
思路
區間dp石子合併經典問題, 見藍皮書284頁
第十題:#include
#include
#include
#include
using
namespace std;
int n;
int a[
110]
, sum[
110]
;int f[
110]
[110];
intmain()
for(
int len =
2; len <= n; len++
)//區間長度 }}
cout << f[1]
[n]<< endl;
return0;
}
暴力列舉
**
字串hash** 不能全過#include
#include
#include
#include
using
namespace std;
string s[
110]
;int n;
string get_ans
(string t,
int k)}}
return ans;
}int
main()
return0;
}
#include
#include
#include
#include
using
namespace std;
typedef
unsigned
long
long ull;
const
int n =
110, p =
13331
;ull p[n]
[n], h[n]
[n];
int n, m;
char s[n]
[n];
ull query
(int l,
int r,
int i)
intmain()
for(
int k =
1; k <= n; k++)}
for(
int i =
1; i <= n; i++
)else
break;}
}for
(int k =
1; k <= len; k++
)printf
("%c"
, s[i]
[k])
; cout << endl;
}}
美團點評2020校招測試方向筆試題
時間限制 c c 1秒,其他語言2秒 空間限制 c c 256m,其他語言512m 將給定的字串,按照規則刪除字元,輸出刪除後的字串。刪除規則為 相同字元連續,則刪除,如 aaaab 刪除後的字串為 b 注 僅是單個字元連續才刪除,如babababa則不能刪除 輸入描述 輸入資料有多組,每組一行,僅...
校招 面試 美團點評 後端開發工程師
1.程式設計題 給定整數陣列a 3 4 5 8 11 9 4 7 6 整數t 12,輸出陣列a的子陣列b a的若干連續元素組成 的長度,滿足b的元素之和大於t,且b的元素數最少。答 暴力求解 列舉所有子陣列,分別求和,找到滿足條件的最短的子陣列。複雜度為o n 2 設定游標 設定左游標和右游標,右游...
2018美團點評校招 K的倍數
序列中任意個連續的元素組成的子串行被稱為該序列的字串 現在給你乙個序列p和乙個整數k,詢問元素和是k的倍數的子串的最大長度 比如序列,給定的整數k為5,其中滿足條件的子串為 那麼答案就為5,因為最長的子串為 如果滿足條件的子串不存在,就輸出0 輸入 第乙個含乙個整數n,1 n 10 5 第二行包含n...