题目链接:http://codeforces.com/problemset/problem/1176/A


思路:贪心,对第二个操作进行俩次等于将n变成n/3,第三个操作同理,我们将n不断除以2,再除以3,最后除以5,判断最后是否等于1即可。

AC代码:

 #include<iostream>
using namespace std;
long long n,ans;
int main(){
int T;
cin >> T;
while(T--){
cin >> n;
ans = ;
while(n % == )n /= ,ans++;
while(n % == )n /= ,ans += ;
while(n % == )n /= ,ans += ;
if(n == ) cout << ans << endl;
else cout << - << endl;
}
return ;
}

Codeforces 1176A Divide it!的更多相关文章

  1. CodeForces - 1176A Divide it! (模拟+分类处理)

    You are given an integer nn. You can perform any of the following operations with this number an arb ...

  2. codeforces 792C. Divide by Three

    题目链接:codeforces 792C. Divide by Three 今天队友翻了个大神的代码来问,我又想了遍这题,感觉很好,这代码除了有点长,思路还是清晰易懂,我就加点注释存一下...分类吧. ...

  3. A - Divide it! CodeForces - 1176A

    题目: You are given an integer nn. You can perform any of the following operations with this number an ...

  4. CodeForces - 792C Divide by Three (DP做法)

    C. Divide by Three time limit per test: 1 second memory limit per test: 256 megabytes input: standar ...

  5. Codeforces 977D Divide by three, multiply by two(拓扑排序)

      Polycarp likes to play with numbers. He takes some integer number xx, writes it down on the board, ...

  6. Codeforces 1270E - Divide Points(构造+奇偶性)

    Codeforces 题目传送门 & 洛谷题目传送门 显然,直接暴力枚举是不可能的. 考虑将点按横纵坐标奇偶性分组,记 \(S_{i,j}=\{t|x_t\equiv i\pmod{2},y_ ...

  7. CodeForces 792C - Divide by Three [ 分类讨论 ]

    删除最少的数位和前缀0,使得剩下的数能被3整除 等价于各数位数字之和能被3整除. 当前数位和可能是 0, 1, 2(mod 3) 0: 直接处理 1: 删除一个a[i]%3 == 1 或者 两个a[i ...

  8. 3.26-3.31【cf补题+其他】

      计蒜客)翻硬币 //暴力匹配 #include<cstdio> #include<cstring> #define CLR(a, b) memset((a), (b), s ...

  9. Divide by three, multiply by two CodeForces - 977D (思维排序)

    Polycarp likes to play with numbers. He takes some integer number xx, writes it down on the board, a ...

随机推荐

  1. CSScomb.js --- 自定义 CSS 编写风格配置文件

    一.排序分类 1. content overflow position z-index display float ... 表示定位/布局的属性(content比较特殊,作为伪元素不可少的,经常放置于 ...

  2. tarjan求强连通+缩点——cf1248E

    这题好像是DEF里最水的,, /* 建图:如果a认识b,那么从a->b连一条边,将点分成两个集合A,B,没有从A->B的边 求出强连通分量,再造一张新图,新图中任取一个的出度为0的点作为集 ...

  3. BZOJ 2055: 80人环游世界(有上下界的费用流)

    题面 Time Limit: 10 Sec Memory Limit: 64 MB Submit: 693 Solved: 434 [Submit][Status][Discuss] Descript ...

  4. (转)ubuntu 下安装mysql5.5.30的过程以及遇到的问题

    转:http://blog.chinaunix.net/uid-27103408-id-3280584.html 由于实验需要安装mysql,当然我们可以通过sudo apt-get install ...

  5. ios获取软键盘完成事件

    ios获取软键盘完成事件,通过判断input的onBlur事件即可

  6. 使用FTPClient实现文件上传服务器

    import ch.qos.logback.classic.Logger; import org.apache.commons.net.ftp.*; import org.slf4j.LoggerFa ...

  7. Openstack组件部署 — Networking service_Compute Node

    目录 目录 前文列表 安装组件 配置通用组件 配置自服务网络选项 配置Linux 桥接代理 配置Nova使用网络 完成安装 验证操作Execute following commands on Cont ...

  8. UDP 协议解析 - 1

    目录 1. 概述 2. UDP 的主要特点 3. UDP 的首部格式 3. UDP 校验和 3.1 伪首部 3.2 UDP 校验和计算方法 [参考文献] 1. 概述 用户数据报协议(UDP,User ...

  9. 技巧&注意事项合集

    技巧&注意事项合集 杂项 OI Wiki有很多实用的东西 编程环境 打开Dev-C++中工具-编译选项-代码生成/优化-代码警告-显示最多警告信息的开关,可以检查出一堆傻逼错误 define ...

  10. Java 设计模式之 装饰者模式

    装饰者模式(Decorator Pattern): 概述:装饰模式是在不必改变原类文件和使用继承的情况下,动态地扩展一个对象的功能.它是通过创建一个包装对象,也就是装饰来包裹真实的对象 特点: (1) ...