主页
试题仓库
题目列表
试题分类
经典教材
作业竞赛
作业列表
判题队列
图灵学院
TuringMOOC
图灵书屋
图灵商城
图灵实验室
图灵会员
荣誉成绩
捐赠支持
图灵云编译器
用户/排名
AOJ排名
实名认证
请登录
常用链接
AOJ考试平台
老赵的Gitee代码
编译原理模拟考试平台
Java技术手册
FCC网站
菜鸟网
在线工具箱
字节豆包GPT
代码可视化
力扣网
牛客网
洛谷
杭电OJ
CodeForce
隐藏编译器
Problem 2981 --Harmonious Army
2981: Harmonious Army
上一题
正确率: $0.00\%$
下一题
Time Limit
$1$ 秒/Second(s)
Memory Limit
$512$ 兆字节/Megabyte(s)
提交总数
$0$
正确数量
$0$
"
裁判形式
标准裁判/Standard Judge
我的状态
尚未尝试
难度
分类标签
×
为本题添加算法分类(请不要超过5个)
当前分类(单击移除):
单击选择分类:
Description
<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">Now, Bob is playing an interesting game in which he is a general of a harmonious army. There are </span>nn<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">soldiers in this army. Each soldier should be in one of the two occupations, Mage or Warrior. There are </span>mm<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> pairs of soldiers having combination ability. There are three kinds of combination ability. If the two soldiers in a pair are both Warriors, the army power would be increased by </span>aa<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">. If the two soldiers in a pair are both Mages, the army power would be increased by </span>cc<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">. Otherwise the army power would be increased by </span>bb<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, and </span>b=a/4+c/3b=a/4+c/3<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, guaranteed that </span>4|a4|a<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> and </span>3|c3|c<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">. Your task is to output the maximum power Bob can increase by arranging the soldiers' occupations. </span><br /> <br /> <span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">Note that the symbol </span>a|ba|b<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> means that </span>aa<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> divides </span>bb<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, e.g. , </span>3|123|12<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> and </span>8|248|24<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">.</span>
Input
<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">There are multiple test cases. </span><br /> <br /> <span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">Each case starts with a line containing two positive integers </span>n(n≤500)n(n≤500)<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> and </span>m(m≤104)m(m≤104)<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">. </span><br /> <br /> <span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">In the following </span>mm<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> lines, each line contains five positive integers </span>u,v,a,b,cu,v,a,b,c<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> </span>(1≤u,v≤n,u≠v,1≤a,c≤4×106,b=a/4+c/3)(1≤u,v≤n,u≠v,1≤a,c≤4×106,b=a/4+c/3)<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, denoting soldiers </span>uu<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> and </span>vv<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> have combination ability, guaranteed that the pair </span>(u,v)(u,v)<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> would not appear more than once. </span><br /> <br /> <span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">It is guaranteed that the sum of </span>nn<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> in all test cases is no larger than </span>5×1035×103<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">, and the sum of </span>mm<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);"> in all test cases is no larger than </span>5×1045×104<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">.</span>
Output
<span style="font-family:Merriweather, serif;font-size:18px;background-color:rgba(210, 210, 255, 0.5);">For each test case, output one line containing the maximum power Bob can increase by arranging the soldiers' occupations.</span>
Sample Input
3 2 1 2 8 3 3 2 3 4 3 6
Sample Output
12
推荐代码
查看2981 所有题解
上传题解视频得图灵币
本题记录
用 户(点击查看用户)
运行号(点击购买题解)
时 间
算法最快[$0 $ms]
0
内存最少[$0 $KB]
0
第一AC
0
第一挑战
0
赛题来源
2019 Multi-University Training Contest 2
登录后提交代码
题面与样例可直接查看,登录后即可在线提交和评测。
前往登录