Codeforces 1176A Divide it!
题目链接: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!的更多相关文章
- CodeForces - 1176A Divide it! (模拟+分类处理)
You are given an integer nn. You can perform any of the following operations with this number an arb ...
- codeforces 792C. Divide by Three
题目链接:codeforces 792C. Divide by Three 今天队友翻了个大神的代码来问,我又想了遍这题,感觉很好,这代码除了有点长,思路还是清晰易懂,我就加点注释存一下...分类吧. ...
- A - Divide it! CodeForces - 1176A
题目: You are given an integer nn. You can perform any of the following operations with this number an ...
- CodeForces - 792C Divide by Three (DP做法)
C. Divide by Three time limit per test: 1 second memory limit per test: 256 megabytes input: standar ...
- 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, ...
- Codeforces 1270E - Divide Points(构造+奇偶性)
Codeforces 题目传送门 & 洛谷题目传送门 显然,直接暴力枚举是不可能的. 考虑将点按横纵坐标奇偶性分组,记 \(S_{i,j}=\{t|x_t\equiv i\pmod{2},y_ ...
- CodeForces 792C - Divide by Three [ 分类讨论 ]
删除最少的数位和前缀0,使得剩下的数能被3整除 等价于各数位数字之和能被3整除. 当前数位和可能是 0, 1, 2(mod 3) 0: 直接处理 1: 删除一个a[i]%3 == 1 或者 两个a[i ...
- 3.26-3.31【cf补题+其他】
计蒜客)翻硬币 //暴力匹配 #include<cstdio> #include<cstring> #define CLR(a, b) memset((a), (b), s ...
- 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 ...
随机推荐
- 「题解」:$Six$
问题 A: Six 时间限制: 1 Sec 内存限制: 512 MB 题面 题面谢绝公开. 题解 来写一篇正经的题解. 每一个数对于答案的贡献与数本身无关,只与它包含了哪几个质因数有关. 所以考虑二 ...
- 牛客网暑期ACM多校训练营(第五场) Agpa (最大化平均值)
题目大意: 给定 n 门课以及它们的学分和绩点,定义总绩点是所有课的加权平均数,给定一个数 k, 你可以删除最多 k 门课,求你的总绩点最大能到多少 分析: 上面是牛客的官方题解,其实就是移项, 然后 ...
- windows10自动更新好烦啊
cmd下输入services.msc,找到windows update,把手动变成禁用. https://blog.csdn.net/hwzzyr/article/details/81190442 h ...
- psql内部命令及对应sql语句
\?: 查看所有帮助 \l: 查看所有数据库 SELECT d.datname as "Name", pg_catalog.pg_get_userbyid(d.da ...
- error LNK2019: 无法解析的外部符号 "__declspec(dllimport) long __stdcall RtlGetVersion(struct _OSVERSIONINFOW
虽然ntdll.lib库也引用了,但还是提示找不到RtlGetVersion函数定义,工程中头文件的定义如下: NTSYSAPI NTSTATUS NTAPI RtlGetVersion( _ ...
- UVA 10242 Fourth Point
题意:给你平行四边形两条边的顶点,让你求第四个点. 思路:要找到俩边的公共点,然后向量运算. AC代码: #include<cstdio> #include<cmath> #i ...
- 剑指offer——46数字序列中某一位的数字
题目: 数字以0123456789101112131415…的格式序列化到一个字符序列中.在这个序列中,第5位(从0开始计数)是5,第13位是1,第19位是4,等等.请写一个函数,求任意第n位对应的数 ...
- hadoop命令行
持续更新中................ 1. 设置目录配额 命令:hadoop dfsadmin -setSpaceQuota 样例:hadoop dfsadmin -setSpaceQuota ...
- JDK8新特性之重复注解
什么是重复注解 下面是JDK8中的重复注解(java.lang.annotation.Repeatable)定义的源码. @Documented @Retention(RetentionPolicy. ...
- linux部署tomcat项目
unzip apache-tomcat-7.0.55-windows- x64.zip 解压zip文件 chmod +x startup.sh shutdown.sh catalina.sh ...