A题:
思路:
非常简单,第二个样例看了之后应该就可以发现规律了吧
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N][N];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cout << a[n - i + 1][n - j + 1] << " ";
}
cout << "\n";
}
return 0;
}
B题:
思路:
先把符合要求的基金的数量算出来,设数量为:
每个基金就只有选和不选两种情况,但是不可以都不选,所以,答案就是:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll power(ll x, ll y) {
ll ans = 1;
while (y--) {
ans = ans * x % mod;
}
return ans;
}
int main() {
int n, x, y;
cin >> n >> x >> y;
int tot = 0;
for (int i = 1; i <= n; i++) {
int a, b;
cin >> a >> b;
if (!(a < x || b > y)) {
tot++;
}
}
cout << power(2, tot) - 1 << "\n";
return 0;
}
后面的题过一会儿再写吧