牛客练习赛64 A 怪盗-1412 平分1的个数

链接:https://ac.nowcoder.com/acm/contest/5633/A
来源:牛客网

题目描述
一个长度为n+m+k{n+m+k}n+m+k包含n{n}n个数字1{1}1,m{m}m个数字2{2}2和k{k}k个数字4{4}4的数组,最多可能有多少个子序列1412{1412}1412?
如果一个序列是数组的子序列,当且仅当这个序列可以由数组删去任意个元素,再将数组中的剩余元素按顺序排列而成。
输入描述:

第一行一个整数t{t}t,表示测试用例的组数。
接下来t{t}t行每行三个整数n,m,k{n,m,k}n,m,k表示一组测试用例。

输出描述:

对于每组测试用例输出一行一个整数表示答案。

示例1
输入
复制

3
6 7 8
1 2 2
6 0 3

输出
复制

504
0
0

备注:

1<=t<=200000{1<=t<=200000}1<=t<=200000
0<=n,m,k<=10000{0<=n,m,k<=10000}0<=n,m,k<=10000




很()容易想到:

  • 形如1111444411112222的一定是满足题意的最优方案
  • 即把1平分放到4的左右两边
    • n为奇数时左边放 n / 2 + 1 n/2+1 n/2+1 1 1 1,右边放 n / 2 n/2 n/2 1 1 1
    • n n n为偶数时左边和右边都放 n / 2 n/2 n/2 1 1 1
#define debug
#ifdef debug
#include <time.h>
#include "/home/majiao/mb.h"
#endif

#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>

#define MAXN ((int)1e6+7)
#define ll long long int
#define int long long int
#define INF (0x7f7f7f7f)
#define fori(lef, rig) for(int i=lef; i<=rig; i++)
#define forj(lef, rig) for(int j=lef; j<=rig; j++)
#define fork(lef, rig) for(int k=lef; k<=rig; k++)
#define QAQ (0)

using namespace std;

#ifdef debug
#define show(x...) \ do { \ cout << "\033[31;1m " << #x << " -> "; \ err(x); \ } while (0)

void err() { cout << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#endif

#ifndef debug
namespace FIO {
	template <typename T>
	void read(T& x) {
		int f = 1; x = 0;
		char ch = getchar();

		while (ch < '0' || ch > '9') 
			{ if (ch == '-') f = -1; ch = getchar(); }
		while (ch >= '0' && ch <= '9') 
			{ x = x * 10 + ch - '0'; ch = getchar(); }
		x *= f;
	}
};
using namespace FIO;
#endif


int n, m, Q, K;

signed main() {
#ifdef debug
	freopen("test", "r", stdin);
	clock_t stime = clock();
#endif
	read(Q);
	while(Q--) {
		scanf("%lld %lld %lld ", &n, &m, &K);
		int lef = n&1 ? n/2+1 : n/2;
		int rig = n/2;
		printf("%lld\n", lef*rig*m*K);
	}


#ifdef debug
	clock_t etime = clock();
	printf("rum time: %lf 秒\n",(double) (etime-stime)/CLOCKS_PER_SEC);
#endif 
	return 0;
}




全部评论

相关推荐

Ryan188:我觉得你简历最核心的问题就是太大众化。 你要有一个认知就是,如果你是面试官,你是HR,其实他们每天都会收到非常多大量重复的像你这种简历。 就是说你的项目不是一个真实的上线的项目,可能是从网上学习而来的,或者是直接copy别人的项目,没有新意,没有展现出你自己对技术的思考,而且你的学历也不占优,自然而然就很难有人去选择你。 所以要做的实际上是差异化方向的工作,也就是“给我一个选择你的理由”,比如最近很火的ai,你可以写一个ai相关项目比如问答应用或者mcp编写或者agent搭建,需要你先花点时间学习,34天吧,展现你对这方面相较于其他人特有的思考; 或者写相关技术博客输出一些技术内容,有具体可以量化的成果等等去增加你的竞争力。 但以上这些都是后话,我去年在你这个时候也是没人理我,咱们双非学历也没实习,难找也正常,我当时整个3月份都没人鸟我,直到有个新招的岗位,很缺人很急,流程很快,所以我一下子进去了,所以运气方面也很重要,需要你一直坚持喝复盘,直到看到光明,加油兄弟
简历被挂麻了,求建议
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务