牛客练习赛64-A
怪盗-1412
https://ac.nowcoder.com/acm/contest/5633/A
牛客练习赛64-A
题目描述
一个长度为n+m+k包含n个数字1,m个数字2和k个数字4的数组,最多可能有多少个子序列1412?
如果一个序列是数组的子序列,当且仅当这个序列可以由数组删去任意个元素,再将数组中的剩余元素按顺序排列而成。
输入描述:
第一行一个整数t,表示测试用例的组数。
接下来t行每行三个整数n,m,k表示一组测试用例。
输出描述:
对于每组测试用例输出一行一个整数表示答案。
输入
3
6 7 8
1 2 2
6 0 3
输出
504
0
0
签到题
1.考虑构成142的情况有多少种,很明显可以111...444...222 这样排列的话 ans=num[1] * num[4] * num[2]
2.那么这个题就削微难了一丢丢,但是也可以想到是111...444...111...222... 这么排列的话ans=num1[1] * num[4] * num2[1] * num[2]
3.那么num1[1]+num2[1]=num[1] 求num1[1] * num2[1] 的最大值显然可得 num1[1]=num[1] / 2
4.ans=num[2] * num[4] * num[1]/2 * (num[1]-num[1]/2)
5.签到完成
#pragma GCC optimize(3,"Ofast","inline") //G++ #include<bits/stdc++.h> #define mem(a,x) memset(a,x,sizeof(a)) #define debug(x) cout << #x << ": " << x << endl; #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define fcout cout<<setprecision(4)<<fixed using namespace std; typedef long long ll; //====================================== namespace FastIO{ char print_f[105];void read() {}void print() {putchar('\n');} template <typename T, typename... T2> inline void read(T &x, T2 &... oth){x = 0;char ch = getchar();ll f = 1;while (!isdigit(ch)){if (ch == '-')f *= -1;ch = getchar();}while (isdigit(ch)){x = x * 10 + ch - 48;ch = getchar();}x *= f;read(oth...);} template <typename T, typename... T2> inline void print(T x, T2... oth){ll p3=-1;if(x<0) putchar('-'),x=-x;do{print_f[++p3] = x%10 + 48;}while(x/=10);while(p3>=0) putchar(print_f[p3--]);putchar(' ');print(oth...);}} // namespace FastIO using FastIO::print; using FastIO::read; //====================================== typedef pair<int,int> pii; const int inf=0x3f3f3f3f; const int mod=1e9+7; const int maxn = 1e6+5; int main() { #ifndef ONLINE_JUDGE // freopen("H:\\code\\in.in", "r", stdin); // freopen("H:\\code\\out.out", "w", stdout); clock_t c1 = clock(); #endif //************************************** int T; read(T); while(T--){ ll n,m,k; read(n,m,k); ll t=n/2; ll ans=t*(n-t)*m*k; print(ans); } //************************************** #ifndef ONLINE_JUDGE cerr << "Time:" << clock() - c1 << "ms" << endl; #endif return 0; }
第一次在牛客写博客,恭喜你成为第一个题^_^