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. mysql登录错误或者密码错误

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

  2. JavaScript中创建命名空间

    引用:http://ourjs.com/detail/538d8d024929582e6200000c   在JavaScript中全局变量经常会引起命名冲突,甚至有时侯重写变量也不是按照你想像中的顺 ...

  3. vb 添加状态栏

    1.新建一工程2.添加"部件" ms windows common controls 6.03.将StatusBar控件加至窗体中4.右键点击该控件,选"属性" ...

  4. 用C语言制作小型商品信息管理系统过程中的问题

    大神请默默飘过... 以下是第一次制作时的源码: // 商品信息管理.cpp : 定义控制台应用程序的入口点. // // 小型商品信息管理系统.cpp : 定义控制台应用程序的入口点. // #in ...

  5. JQ中$(document.ready())

    js中window.onload与jquery中$(document.ready())的区别 <html> <head> <script type='text/javas ...

  6. uber在限制新司机加入了,看看新政策把

    您可以点击“车主奖励分组查询”输入您在系统注册的手机号查询您所在奖励分组 5月25日-5月31日 奖励明细 1. 成都优步合作车主第一组 奖励政策: (账户激活时间在2015年5月29日之前) *以下 ...

  7. javascript数组去重算法-----4

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. 利用sass构建组件化的ui库

    创建公用的Sass项目模板 在做项目时,不管什么项目,他们之间总是有一些可以共用的部分.比如说重置样式.公用样式.模块组件.UI库等.那么在Sass项目中也是如此.为了避免在每个项目中做一些相同的事情 ...

  9. css3动画工具

    去年,我刚刚开始学习css3时候,看到了腾讯的这个工具,引起了我对css3的兴趣. 配合着书本上的知识写了一些效果,感觉不错. http://www.f2e.name/case/css3/tools. ...

  10. java数据库连接

    注意点: 1.所有和数据库相关的(jdbc)包都是java.sql.*: 2.将项目所需的jar包统一复制到web-inf/lib文件夹中. 一:sqlsever数据库 package dbcon; ...