原创 1073C. Vasya and Robot
1073C. Vasya and Robot 注意如果 d 和 n 奇偶性不一致則是不可能到達的,因爲機器人每移動一步,其座標之和的奇偶性就會發生變化。 #include<bits/stdc++.h> using namespace
原创 1073B. Vasya and Books
1073B. Vasya and Books #include<bits/stdc++.h> using namespace std; const int maxn = 2*100000 + 5; int n,s[maxn],t[max
原创 1354:Mobile Computing
Mobile Computing 枚舉二叉樹然後計算其寬度即可,每次枚舉兩個節點構造一個父節點,計算寬度時需要注意的是每棵樹的左節點的右邊緣可能超過其右子樹的左邊緣,反之亦然。 #include<bits/stdc++.h> using
原创 16. 3Sum Closest
16. 3Sum Closest 和之前3Sum那道題思路一樣,剛開始想的是不用每次計算誤差,只需要在小於目標和大於目標的轉折點出計算兩次然後臨界的時候計算一次即可,可是實際上和每次都計算誤差速度一樣的。。。 class Solutio
原创 8. String to Integer (atoi)
8. String to Integer (atoi) class Solution { public: int myAtoi(string str) { int Max = (1<<31)-1, Min = -
原创 15. 3Sum
15. 3Sum class Solution { public: vector<vector<int>> threeSum(vector<int>& nums) { sort(nums.begin(),nums
原创 10976:Fractions Again?!
Fractions Again?! x 要用 long long。 #include<bits/stdc++.h> using namespace std; const int maxk = 10000; int k; long lon
原创 725:Division
Division #include<bits/stdc++.h> using namespace std; const int maxn = 64 + 5; int n,a[30240][6]; int num,kase = 0,cnt
原创 13. Roman to Integer
13. Roman to Integer int romanToInt(char* s) { int dic[26]; dic['I'-'A'] = 1; dic['V'-'A'] = 5; dic['
原创 14. Longest Common Prefix
14. Longest Common Prefix char s[100000]; int min(int a,int b){ return a < b ? a : b; } char* longestCommonPrefix(
原创 536:Tree Recovery
Tree Recovery #include<bits/stdc++.h> using namespace std; const int maxn = 30; struct node{ char c; struct no
原创 12. Integer to Roman
12. Integer to Roman char s[100]; char* intToRoman(int num) { char rs[] = "MDCLXVI"; int ts[] = { 1000,500,100
原创 11059:Maximum Product
Maximum Product #include<bits/stdc++.h> using namespace std; const int maxn = 20; int n; int seq[maxn]; int main() {
原创 11853:Paintball
Paintball #include<bits/stdc++.h> using namespace std; const int maxn = 1000 + 5; int n; int ops[maxn][3]; int G[maxn]
原创 129:Krypton Factor
Krypton Factor 注意 && 別寫成 & 了。。。 #include<bits/stdc++.h> using namespace std; const int maxn = 80 + 5; int n,L,cnt; int