BC第二场
GT and sequence
You are given a sequence of NN integers.
You should choose some numbers(at least one),and make the product of them as big as possible.
It guaranteed that the absolute value of any product of the numbers you choose in the initial sequence will not bigger than 2^{63}-1263−1.
In the first line there is a number TT (test numbers).
For each test,in the first line there is a number NN,and in the next line there are NN numbers.
1 \leq T \leq 10001≤T≤1000 1 \leq N \leq 621≤N≤62
You'd better print the enter in the last line when you hack others.
You'd better not print space in the last of each line when you hack others.
For each test case,output the answer.
1
3
1 2 3
6
题解:各种考虑,细心点。。。。
ac代码:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
const int MAXN=;
typedef long long LL;
int cmp(LL a,LL b){
return a>b;
}
int main(){
int T,N;
LL m[MAXN];
scanf("%d",&T);
while(T--){
scanf("%d",&N);
LL x,ans=;
int zheng=,fu=,o=;
for(int i=;i<N;i++){
scanf("%I64d",&x);
if(x>)ans*=x,zheng++;
else if(x<)m[fu++]=-x;
else o++;
}
if(!zheng){
if(!fu){
puts("");continue;
}
else if(o&&fu==){
puts("");continue;
}
else if(!o&&fu==){
printf("%I64d\n",-m[]);
continue;
}
}
if(fu==){
printf("%I64d\n",ans);continue;
}
sort(m,m+fu,cmp);
//for(int i=0;i<fu;i++)printf("%d ",m[i]);puts("");
for(int i=;i<(fu/)*;i++)ans*=m[i];
printf("%I64d\n",ans);
}
return ;
}
GT and numbers
You are given two numbers NN and MM.
Every step you can get a new NN in the way that multiply NN by a factor of NN.
Work out how many steps can NN be equal to MM at least.
If N can't be to M forever,print -1−1.
In the first line there is a number TT.TT is the test number.
In the next TT lines there are two numbers NN and MM.
T\leq1000T≤1000, 1\leq N \leq 10000001≤N≤1000000,1 \leq M \leq 2^{63}1≤M≤263.
Be careful to the range of M.
You'd better print the enter in the last line when you hack others.
You'd better not print space in the last of each line when you hack others.
For each test case,output an answer.
3
1 1
1 2
2 4
0
-1
1
wa代码:
HACK
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int cmd(int a,int b){
return a>b;
}
int main(){
__int64 T,N,M;
scanf("%I64d",&T);
__int64 fac[];
while(T--){
scanf("%I64d%I64d",&N,&M);
if(M%N!=){
puts("-1");
continue;
}
__int64 t=;
__int64 n=N;
for(__int64 i=;i<=n;i++){
if(n%i==){
fac[t++]=i;
}
}
n=M/N;
__int64 ans=;
sort(fac,fac+t,cmd);
for(__int64 i=;i<t;i++){
while(n%(fac[i])==)n/=fac[i],ans++;
}
// for(int i=0;i<t;i++)printf("%d ",fac[i]);puts("");
if(n==)printf("%I64d\n",ans);
else puts("-1");
}
return ;
}
BC第二场的更多相关文章
- 本周进步要点20161023(含李笑来第二场live笔记要点)
本周主要忙于去武汉参加iDOF2016智能数字油田会议,会上做了题为“油田SOA及云平台的系统思考与实践”的报告,为了准备这篇报告,用到了一些以前学过的知识,具体内容见“参加iDOF2016会议的收获 ...
- 2014百度之星预赛(第二场)——Best Financing
2014百度之星预赛(第二场)--Best Financing Problem Description 小A想通过合理投资银行理財产品达到收益最大化.已知小A在未来一段时间中的收入情况,描写叙述为两个 ...
- Contest1592 - 2018-2019赛季多校联合新生训练赛第二场(部分题解)
Contest1592 - 2018-2019赛季多校联合新生训练赛第二场 D 10248 修建高楼(模拟优化) H 10252 组装玩具(贪心+二分) D 传送门 题干 题目描述 C 市有一条东西走 ...
- 2018牛客暑期ACM多校训练营第二场(有坑未填)
第二场终于等来学弟 开始(被队友带飞)的开心(被虐)多校之旅 A run A题是一个递推(dp?)+前缀和 因为看数据量比较大 就直接上前缀和了 一个比较简单的递推 没有太多难点 签到题 需要注意 ...
- 2018牛客网暑假ACM多校训练赛(第二场)E tree 动态规划
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round2-E.html 题目传送门 - 2018牛客多校赛第二场 E ...
- NOI.AC NOIP模拟赛 第二场 补记
NOI.AC NOIP模拟赛 第二场 补记 palindrome 题目大意: 同[CEOI2017]Palindromic Partitions string 同[TC11326]Impossible ...
- DevOps Workshop 研发运维一体化(北京第二场) 2016.04.27
北京不亏为首都,人才济济,对微软DevOps解决方案感兴趣的人太多.我们与微软公司临时决定再家一场培训. 我之前在博客中(DevOps Workshop 研发运维一体化第一场(微软亚太研发集团总部)h ...
- CTF-i春秋网鼎杯第二场misc部分writeup
CTF-i春秋网鼎杯第二场misc部分writeup 套娃 下载下来是六张图片 直接看并没有什么信息 一个一个查看属性 没有找到有用信息 到winhexv里看一下 都是标准的png图片,而且没有fla ...
- 2018 计算之道初赛第二场 阿里巴巴的手机代理商(困难)(反向可持久化Trie)
阿里巴巴的手机代理商(困难) 阿里巴巴的手机代理商正在研究 infra 输入法的新功能.他们需要分析单词频率以改进用户输入法的体验.于是需要你在系统内核里面写一个 API. API 有如下功能: 添加 ...
随机推荐
- linux杂记(三)linux指令介绍
[root@linux ~]# command [-options] parameter1 parameter2 说明: 最左边的root显示的是[目前使用者的账号],而@之后接的是linux即[主机 ...
- HTML5 canvas易错点
一.画布的默认宽高 <canvas id="myCanvas" style="border:1px solid black;"> 你的浏览器不支持h ...
- 【转】MUD教程--巫师入门教程1
<新巫师入门手册> 第一章:观念篇■ 内容提要:什么是巫师?怎样做一个巫师?如何做好一个巫师? 第二章:上手篇■ 内容提要:最简单的房间怎么写?NPC又怎么写?先看懂一些常用的参数? 第三 ...
- CPU核心数
Process.ProcessorAffinity 属性: public IntPtr ProcessorAffinity { get; set; }属性值:位掩码,表示关联进程内的线程可以在其上运行 ...
- Stream与byte转换
将 Stream 转成 byte[] /// <summary> /// 将 Stream 转成 byte[] /// </summary> public byte[] Str ...
- verilog中阻塞复制,非阻塞复制,顺序块,并行块之间的关系
这几个概念是不一样的 顺序块:顺序块中的语句是按顺序执行的,每条语句中的延迟值是与其前一条语句执行的仿真时间有关. 并行块:并行块语句是并行执行的,它里面的每条语句中指定的延迟值都是相对于语句块开始执 ...
- 19.java.lang.NoClassDefFoundException
java.lang.NoClassDefFoundException未找到类定义错误 当Java虚拟机或者类装载器试图实例化某个类,而找不到该类的定义时抛出该错误. 违背安全原则异常:Secturit ...
- Cortex-M3学习日志(五) -- DAC实验
终于逮了个忙里偷闲的机会,就再学一下LPC1768的外围功能吧,循序渐进是学习的基本规则,也许LPC1768的DAC与8位单片机16位单片机里面集成的DAC操作类似,但是既然这是懒猫的学习日志,就顺便 ...
- k8s 集群基本概念
一.概述: kubernetes是google开源的容器集群管理系统,提供应用部署.维护.扩展机制等功能,利用kubernetes能方便管理跨集群运行容器化的应用,简称:k8s(k与s之间有8个字母) ...
- oracle表设置主键自增长
create or replace table TBL_SYS_USER ( user_id NUMBER(19) not null, user_name ...