https://codeforces.com/contest/1236/problem/A
#include<bits/stdc++.h> using namespace std; int main(){ int t,a,b,c; cin >> t; while(t--) { cin >> a>> b>>c; int x = c/2, sum = 0; sum += 3*min(x, b); b -= min(x,b); int y = b/2; sum += min(a, y) *3; cout << sum << endl; } return 0; }
https://codeforces.com/contest/1236/problem/B
First, we can think about putting one present in m boxs, each box has two conditions(put or not) ,so the res is 2^m, and we should subtract 1(all boxs are empty).(the answer one present in m boxs is 2^m-1)
Then we have n presents, so the amnswer is (2^m-1)^n,
#include<bits/stdc++.h> using namespace std; #define ll long long const ll mod = 1e9+7; ll fpow(ll a, ll b) { ll ret = 1; while(b) { if(b & 1) ret = ret*a%mod; a = a*a%mod; b >>= 1; } return ret; } int main(){ int t; t = 1; //cin >> t; while(t--) { ll a,b; cin >> a >> b; if(b == 1) cout << "1\n"; else cout << fpow(fpow(2, b)-1, a) << endl; } return 0; }
https://codeforces.com/contest/1236/problem/C
The maximum number is ⌊n22⌋⌊n22⌋. 具体证明不会 emmmmmmmm
可以蛇形填数(如下)
1 6 7
2 5 8
3 4 9
#include<bits/stdc++.h> using namespace std; #define ll long long #define _for(i,a,b) for(int i = (a); i < (b); i++) #define _rep(i,a,b) for(int i = (a); i <= (b); i++) const ll mod = 1e9+7; int main(){ int t,a,b,c; t = 1; //cin >> t; while(t--) { int dp[303][303]; cin >> a; _rep(j,1,a) { if(j&1) _for(i,0,a) dp[i][j] = 1+(j-1)*a+i; else _for(i,0,a) dp[i][j] = j*a-i; } _rep(i,0,a-1) _for(j,1,a+1) cout << dp[i][j] <<(j==a?"\n":" "); } return 0; } /* 2 8 5 9 3 4 7 6 1 */
https://codeforces.com/contest/1236/problem/D
https://codeforces.com/contest/1236/problem/E