Problem Description

定义操作:将数 n 变为 f(n) = floor(sqrt(n))。即对一个数开平方后,再向下取整。
如对 2 进行一次操作,开平方再向下取整, 1.414213562..... = 1 , 即变为了 1 。
现在给出一个数 n,如果能在 5 次操作内把 n 变为 1,则输出操作次数;如果则超过5次输出"QAQ"。
数据范围:
1<= n <= 10^100

Input

多组输入,每行输入一个数 n。

Output

每组数据输出要多少次操作,或者输出"QAQ"

Sample Input

233
233333333333333333333333333333333333333333333333333333333

Sample Output

3
QAQ 解法:当然是暴力跑出结果啦
 #include<bits/stdc++.h>
using namespace std;
int main(){
string s;
while(cin>>s){
int cnt=;
long long n=;
if(s.length()>=){
cout<<"QAQ"<<endl;
}else{
for(int i=;i<s.length();i++){
n*=;
n+=s[i]-'';
}
if(n<){
while(n>){
cnt++;
n=sqrt(n);
}
cout<<cnt<<endl;
}else{
cout<<"QAQ"<<endl;
}
}
}
}
 import math
for i in range(4011110000,5011110000):
num =math.sqrt(math.sqrt(math.sqrt(math.sqrt(math.sqrt(i)))))
if num >=2: # 确定第一个因子
print(i)
break

最新文章

  1. 一个section刷新 一个cell刷新
  2. SNMP OID列表 监控需要用到的OID
  3. 编写高质量JS代码的68个有效方法(十)
  4. lib3ds类库
  5. HDU 5510 Bazinga 暴力匹配加剪枝
  6. NodeJS安全设计:好吃的草莓味糖果,只给好朋友小红
  7. Libcurl笔记一
  8. 无限循环的ViewPager
  9. 8个华丽的HTML5相册动画欣赏
  10. UIViewController、UINavigationController与UITabBarController的整合使用
  11. NSIS:使用WinVer.nsh头文件判断操作系统版本
  12. HTML 笔记 基础1
  13. TypeScript 学习资料
  14. lanya
  15. mongoDB 的介绍
  16. 数据库SQL语句性能优化
  17. mysql where 条件中的字段有NULL值时的sql语句写法
  18. 【多线程系列】AQS CAS简单介绍
  19. Linux 命令find、grep
  20. Connection连接、关闭数据库

热门文章

  1. xdebug浏览器调试参数
  2. LuoguP4383 [八省联考2018]林克卡特树lct
  3. shader学习推荐
  4. 汇编题目:按A键,当松开的时显示字母A
  5. 洛谷【P1090】合并果子&amp;&amp;洛谷【P1334】瑞瑞的木板
  6. app专项测试(稳定性测试、安全性测试)
  7. MODBUS TCP和MODBUS RTU的差别
  8. net.sf.json-lib maven依赖问题.
  9. Hive中SELECT TOP N的方法(order by与sort by的区别)
  10. python包管理