uva1605
題意:設計一棟有n層的樓,每層都有m行k列的格子,將這些格子分給不同的國家,使得每個國家都有相鄰的格子。
分析:方法很多,因為限制很少,剛開始想復雜了,其實只需要考慮以最簡單的方法將它們兩兩相鄰就好了。
#include<iostream> #include<string> #include<sstream> #include<algorithm> #include<vector> using namespace std;int main() {int n;char w[] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" };while (cin >> n) {cout << "2 " << n << " " << n << endl;for (int i = 0; i < n; i++) {for (int j = 0; j < n; j++) {cout << w[i];}cout << endl;}cout << endl;for (int i = 0; i < n; i++) {for (int j = 0; j < n; j++) {cout << w[j];}cout << endl;}}return 0; }?
總結