springboot不經過controller直接訪問html頁面
阿新 • • 發佈:2020-08-13
目錄
Codeforces Round #664 (Div. 2)
A. Boboniu Likes to Color Balls
題意: 給你四種顏色的球,給你一種操作:選擇前三種各一個,將這三個變成最後一種,你可以執行任意次該操作
問,球的數量可不可以形成迴文
題解: 判斷一下偶數個的是否有3個機以上,如果沒有3個及以上,那麼判斷能不能通過有限次變化變為3個及以上。變化只需要判斷1和2即可
程式碼:
#include <bits/stdc++.h> using namespace std; int T, n, a[4]; int main() { cin >> T; while (T--) { int minv = 1e9 + 10, cnt_even = 0; for (int i = 0; i < 4; ++i) { cin >> a[i]; if (i <= 2) minv = min(minv, a[i]); if (a[i] % 2 == 0) cnt_even ++; } if (cnt_even >= 3) { cout << "YES\n"; continue; } if (minv >= 1) { cnt_even = 0; for (int i = 0; i < 3; ++i) { a[i]--; if (a[i] % 2 == 0) cnt_even ++; } a[3]++; if (a[3] % 2 == 0) cnt_even++; if (cnt_even >= 3) { cout << "YES\n"; continue; } } if (minv >= 2) { cnt_even = 0; for (int i = 0; i < 3; ++i) { a[i] -= 2; if (a[i] % 2 == 0) cnt_even ++; } a[3] += 2; if (a[3] % 2 == 0) cnt_even++; if (cnt_even >= 3) { cout << "YES\n"; continue; } } cout << "NO\n"; } return 0; }
B. Boboniu Plays Chess
題意: 給你一個n×m的方格,給你一個起始點(x,y),你可以像象棋中的車那樣移動,你需要將所有點全部去一次
問你路徑
題解: 本題是構造性問題,只需要找到一直構造方法即可。我的方法是先把(sx, sy)所處的那一行填滿,然後填上半部分,再填下半部分。
程式碼:
#include <bits/stdc++.h> using namespace std; int a[110][110]; int n, m, sx, sy; vector<pair<int, int> > res; int main() { cin >> n >> m >> sx >> sy; // a[sx][sy] = 1; int idx = 1; for (int i = sy; i >= 1; --i) a[sx][i] = idx++, res.push_back({sx, i}); for (int i = sy + 1; i <= m; ++i) a[sx][i] = idx++, res.push_back({sx, i}); int r = sx + 1, c = m, flg = 1; while (r <= n) { a[r][c] = idx++; res.push_back({r, c}); if (flg) c--; else c++; if (c == 0 || c == m + 1) { flg = !flg; r++; if (c == 0) c++; else c--; } } r = sx - 1; // cout << "上半部分:" << r << " " << c << " " << flg << endl; while (r >= 1) { a[r][c] = idx++; res.push_back({r, c}); if (flg) c--; else c++; if (c == 0 || c == m + 1) { flg = !flg; r--; if (c == 0) c++; else c--; } } for (auto r: res) cout << r.first<< " " << r.second << endl; return 0; } /* 2 2 1 2 1 3 2 3 3 3 3 2 3 1 2 1 1 1 */
C. Boboniu and Bit Operations
題意: 給你一個長度為n的序列a,一個長度為m的序列b,其中c[i]=a[i]&b[j]c[i]=a[i]&b[j](j為b中的任意位)
求滿足條件的最小的c[1]∣c[2]∣...∣c[n]c[1]∣c[2]∣...∣c[n]
題解: 由於答案範圍在[0, 511],因此列舉答案,然後每次判斷a[i]&b[j]|x == x是否成立,如果成立,那麼該答案符合條件。可能有人有疑惑,這樣處理可能在x更小的地方取到答案,但是由於x是從小到大列舉,因此如果在更小的地方取到答案,那麼x就取更小的那個。
程式碼:
#include <bits/stdc++.h>
using namespace std;
int const N = 210;
int n, m, a[N], b[N];
bool check(int x) {
for (int i = 1; i <= n; ++i) {
bool flg = 0;
for (int j = 1; j <= m; ++j) {
if (((a[i] & b[j]) | x) == x) {
flg = 1;
break;
}
}
if (!flg) return false;
}
return true;
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
for (int i = 1; i <= m; ++i) scanf("%d", &b[i]);
for (int i = 0; i < (1 << 9); ++i) {
if (check(i)) {
cout << i << endl;
return 0;
}
}
return 0;
}