题目链接: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. Oracle删除修改字段

    Oracle 增加修改删除字段 添加字段的语法:alter table tablename add (column datatype [default value][null/not null],…. ...

  2. Android中父View和子view的点击事件的执行过程

    Android中的事件类型分为按键事件和屏幕触摸事件,Touch事件是屏幕触摸事件的基础事件,有必要对它进行深入的了解.  一个最简单的屏幕触摸动作触发了一系列Touch事件:ACTION_DOWN- ...

  3. 线段树双tag+差分数组——cf1208E

    写了一上午 /* 对于每个数组a[],先排序然后从大到小把a[i]放进线段树更新 设a[i]的位置是pos,那么其可更新的区间是[pos,w-(li-pos)] 线段树结点保存 tag=now表示当前 ...

  4. [SCOI2009]迷路(矩阵快速幂) 题解

    Description windy在有向图中迷路了. 该有向图有 N 个节点,windy从节点 0 出发,他必须恰好在 T 时刻到达节点 N-1. 现在给出该有向图,你能告诉windy总共有多少种不同 ...

  5. share memory

    header for public argument:shmdata.h #define TEXT_SZ 2048 struct shared_use_st { int written; char t ...

  6. 关闭windows的DEP

    1.与开启dep时一样,按组合键win+r打开运行窗口,输入cmd并按回车,如图所示:    2.调出命令提示符窗口后,输入bcdedit.exe/set {current} nx AlwaysOff ...

  7. 机器学习技法笔记:Homework #5 特征变换&Soft-Margin SVM相关习题

    原文地址:https://www.jianshu.com/p/6bf801bdc644 特征变换 问题描述 程序实现 # coding: utf-8 import numpy as np from c ...

  8. Codeforces 1169B Pairs

    题目链接:http://codeforces.com/contest/1169/problem/B 题意:给你 m 对数 ,问你能不能在 1 − n 之间找到俩个不相等的 x 和 y 使得 对于前面每 ...

  9. org.apache.ibatis.builder.IncompleteElementException: Could not find result map com.abc.beans.Minister

    使用mybatis进行一对多嵌套查询时出错,错误原因: <select id="findMinisterById" resultMap="com.abc.beans ...

  10. python接口自动化(post请求)

    python接口自动化(post请求) 一.post请求的作用:新增资源 二.data格式的参数请求(data是字典对象) #1.导包 import requests #2.调用post方法 #请求的 ...