华东交通大学2017年ACM“双基”程序设计竞赛 1010
2024-10-21 13:08:19
Problem Description
定义操作:将数 n 变为 f(n) = floor(sqrt(n))。即对一个数开平方后,再向下取整。
如对 2 进行一次操作,开平方再向下取整, 1.414213562..... = 1 , 即变为了 1 。
现在给出一个数 n,如果能在 5 次操作内把 n 变为 1,则输出操作次数;如果则超过5次输出"QAQ"。
数据范围:
1<= n <= 10^100
如对 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
最新文章
- 一个section刷新 一个cell刷新
- SNMP OID列表 监控需要用到的OID
- 编写高质量JS代码的68个有效方法(十)
- lib3ds类库
- HDU 5510 Bazinga 暴力匹配加剪枝
- NodeJS安全设计:好吃的草莓味糖果,只给好朋友小红
- Libcurl笔记一
- 无限循环的ViewPager
- 8个华丽的HTML5相册动画欣赏
- UIViewController、UINavigationController与UITabBarController的整合使用
- NSIS:使用WinVer.nsh头文件判断操作系统版本
- HTML 笔记 基础1
- TypeScript 学习资料
- lanya
- mongoDB 的介绍
- 数据库SQL语句性能优化
- mysql where 条件中的字段有NULL值时的sql语句写法
- 【多线程系列】AQS CAS简单介绍
- Linux 命令find、grep
- Connection连接、关闭数据库
热门文章
- xdebug浏览器调试参数
- LuoguP4383 [八省联考2018]林克卡特树lct
- shader学习推荐
- 汇编题目:按A键,当松开的时显示字母A
- 洛谷【P1090】合并果子&;&;洛谷【P1334】瑞瑞的木板
- app专项测试(稳定性测试、安全性测试)
- MODBUS TCP和MODBUS RTU的差别
- net.sf.json-lib maven依赖问题.
- Hive中SELECT TOP N的方法(order by与sort by的区别)
- python包管理