GT and sequence

 Accepts: 385
 Submissions: 1467
 Time Limit: 2000/1000 MS (Java/Others)
 Memory Limit: 65536/65536 K (Java/Others)
Problem Description

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}-12​63​​−1.

Input

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.

Output

For each test case,output the answer.

Sample Input
1
3
1 2 3
Sample Output
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

 Accepts: 146
 Submissions: 939
 Time Limit: 2000/1000 MS (Java/Others)
 Memory Limit: 65536/65536 K (Java/Others)
Problem Description

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.

Input

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≤2​63​​.

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.

Output

For each test case,output an answer.

Sample Input
3
1 1
1 2
2 4
Sample Output
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第二场的更多相关文章

  1. 本周进步要点20161023(含李笑来第二场live笔记要点)

    本周主要忙于去武汉参加iDOF2016智能数字油田会议,会上做了题为“油田SOA及云平台的系统思考与实践”的报告,为了准备这篇报告,用到了一些以前学过的知识,具体内容见“参加iDOF2016会议的收获 ...

  2. 2014百度之星预赛(第二场)——Best Financing

    2014百度之星预赛(第二场)--Best Financing Problem Description 小A想通过合理投资银行理財产品达到收益最大化.已知小A在未来一段时间中的收入情况,描写叙述为两个 ...

  3. Contest1592 - 2018-2019赛季多校联合新生训练赛第二场(部分题解)

    Contest1592 - 2018-2019赛季多校联合新生训练赛第二场 D 10248 修建高楼(模拟优化) H 10252 组装玩具(贪心+二分) D 传送门 题干 题目描述 C 市有一条东西走 ...

  4. 2018牛客暑期ACM多校训练营第二场(有坑未填)

    第二场终于等来学弟 开始(被队友带飞)的开心(被虐)多校之旅 A   run A题是一个递推(dp?)+前缀和 因为看数据量比较大 就直接上前缀和了 一个比较简单的递推 没有太多难点 签到题 需要注意 ...

  5. 2018牛客网暑假ACM多校训练赛(第二场)E tree 动态规划

    原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round2-E.html 题目传送门 - 2018牛客多校赛第二场 E ...

  6. NOI.AC NOIP模拟赛 第二场 补记

    NOI.AC NOIP模拟赛 第二场 补记 palindrome 题目大意: 同[CEOI2017]Palindromic Partitions string 同[TC11326]Impossible ...

  7. DevOps Workshop 研发运维一体化(北京第二场) 2016.04.27

    北京不亏为首都,人才济济,对微软DevOps解决方案感兴趣的人太多.我们与微软公司临时决定再家一场培训. 我之前在博客中(DevOps Workshop 研发运维一体化第一场(微软亚太研发集团总部)h ...

  8. CTF-i春秋网鼎杯第二场misc部分writeup

    CTF-i春秋网鼎杯第二场misc部分writeup 套娃 下载下来是六张图片 直接看并没有什么信息 一个一个查看属性 没有找到有用信息 到winhexv里看一下 都是标准的png图片,而且没有fla ...

  9. 2018 计算之道初赛第二场 阿里巴巴的手机代理商(困难)(反向可持久化Trie)

    阿里巴巴的手机代理商(困难) 阿里巴巴的手机代理商正在研究 infra 输入法的新功能.他们需要分析单词频率以改进用户输入法的体验.于是需要你在系统内核里面写一个 API. API 有如下功能: 添加 ...

随机推荐

  1. HTML5 canvas准备知识

    利用canvas来进行画图工作.因此,我们有必要进行一些画图方面的术语说明. 一.画布 在日常生活中,如果我们要画画,可以找纸.板.画布等等工具.而在网页元素中,我们只需要定义一个标签即可. < ...

  2. mysql登录错误或者密码错误

    一.mysql登录错误 mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root ...

  3. JavaWeb基础之tomcat部署

    有些东西,看起来简单,做起来也简单,简单的你并不一定知道! 问题:如何将一个java project转变为 web project,并使其自动部署到tomcat? 1.先建立一个Java Projec ...

  4. skynet初学

    记录下命令 git clone https://github.com/cloudwu/skynet.git sudo apt-get install autoconf sudo apt-get ins ...

  5. Oracle EBS-SQL (SYS-11):查询系统已打的PATCH.sql

    select a.patch_name,         b.DRIVER_FILE_NAME,         c.language,         b.creation_datefrom app ...

  6. 介绍几种IC卡

    介绍几种IC卡 Mifare卡:工作频率:13.56MHZ数据保存期:10年 操作时间:96ms读写距离:2.5-10cm   存储容量:8Kbit尺寸:85.6x54x0.76mm 存储器类型:EE ...

  7. iOS实现文件上传功能模块

    iOS实现文件上传功能,首先要知道的是,上传到服务器的数据格式,一般采用HTTP文件上传协议.如下图 如图所示,只要设置好了HTTP的协议格式,就可以实现文件上传功能. 代码如下: //图片上传模块 ...

  8. server宕机监控、检測、报警程序(139绑定手机短信报警)monitor_down.sh

    宕机监控报警程序 一.   需求来源 宕机对运维人员来说,最痛苦了.怎样检測一台server是否还在正常执行,假设该server宕机,怎样在第一时间监測到并通知一线运维人员进行维护,最大化降低损失. ...

  9. Android 常用开发类库

    android.app :提供高层的程序模型.提供基本的运行环境    android.content :包含各种的对设备上的数据进行访问和发布的类    android.database :通过内容 ...

  10. jvm的内存管理【转】

    [转]JVM内存管理 这些日子一直在研究jvm内存管理的东西,网上的知识很多,总结一下,能沉淀下来的就是自己的! 首先,刚学java的时候就知道java类文件是以 .java为后缀的文件,经过java ...