计算次数,POJ(1207)
题目链接:http://poj.org/problem?id=1207
#include <stdio.h>
#include <algorithm> using namespace std; int i,j;
int Max; int fun(int k)
{
int Count=;
while(k!=)
{
if(k%==)
k=k*+;
else k/=;
Count++;
}
return Count;
} int main()
{
while(scanf("%d%d",&i,&j)!=EOF)
{
int ti=i;
int tj=j;
Max=-;
if(ti>tj)
swap(ti,tj);
for(int k=ti; k<=tj; k++)
{
if(Max<fun(k))
{
Max=fun(k);
}
}
printf("%d %d %d\n",i,j,Max);
}
return ;
}
计算次数,POJ(1207)的更多相关文章
- Linux显示计算次数的结果
Linux显示计算次数的结果 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ free -c free:选项需要一个参数 -- c Usage: free [o ...
- OpenJudge/Poj 1207 The 3n + 1 problem
1.链接地址: http://bailian.openjudge.cn/practice/1207/ http://poj.org/problem?id=1207 2.题目: 总时间限制: 1000m ...
- 时间复杂度 - Convert 计算次数 TO 时间复杂度
我们假设计算机运行一行基础代码需要执行一次运算. int aFunc(void) { printf("Hello, World!\n"); // 需要执行 1 次 return 0 ...
- 字节真题 ZJ26-异或:使用字典树减少计算次数
原题链接 题目描述: 个人分析:从输入数据看,要处理的元素个数(n)没有到达 10^9 或 10^8 级,或许可以使用暴力?但是稍微计算一下,有 10^5 * (10^5 - 1) / 2 = 10^ ...
- POJ 1207 3N+1 Problem
更简单的水题,穷举法即可. 需要注意的点: 1.i 和 j的大小关系不确定,即有可能 i>j 2.即使i>j,最后输出的结果也要严格按照输出,亦即如果输入10,1,则对应输出也应为 10 ...
- 计算多项式Poj(1996)
题目链接:http://poj.org/problem?id=1996 思路: 刚开始打了个二维表,调了一个小时,爆内存了. #include <stdio.h> #include < ...
- poj: 1207
好吧这题竟然还有先大后小的可能,能不这么恶心下吗.. #include <iostream> #include <stdio.h> #include <string.h& ...
- HDOJ 1032(POJ 1207) The 3n + 1 problem
Description Problems in Computer Science are often classified as belonging to a certain class of pro ...
- 求x到y的最少计算次数
链接:https://www.nowcoder.com/questionTerminal/45d04d4d047c48768543eeec95798ed6?orderByHotValue=1& ...
随机推荐
- css display flew 伸缩盒模型
父级容器属 <!doctype html> <html lang="en"> <head> <meta charset="UTF ...
- linux 运维基础测验题
第一题:创建一个目录/data --> mkdir /data eg: ls -d 显示命令 -l 详细信息 -a 显示所有文件 cd 打开目录 pwd 显示当前目录 第二题:在/ ...
- lnmp 一键搭建脚本
转载注明出处!!!!!!!!! 不足之处望多多指教. 不明之处站内私. #!/bin/bash #################################################### ...
- Nmap原理02 - 版本探测介绍(上)
Nmap原理02 - 版本探测介绍(上) 1.介绍 本文将介绍如何通过修改或添加nmap-service-probes文件来实现对nmap中未知服务的探测,首先介绍服务和版本探测的相关信息,然后介绍服 ...
- Ubuntu通过xinput禁用及启用联想笔记本的触摸板
查看设备列表 通过xinput先查看一些都有哪些设备 xinput #或者 xinput list 显示结果如下 ddd@ddd:~$ xinput list Virtual core p ...
- 记自己的hexo个人博客
https://othercoding.github.io/
- 05.while循环的练习
练习1: namespace _05.while循环练习01 { class Program { static void Main(string[] args) { //打印100次"努力学 ...
- 03.if 和 switch结合练习
namespace _04.练习01 { class Program { static void Main(string[] args) { //请用户输入年份,再输入月份,输出该月有多少天 Cons ...
- 2017年11月4日 vs类和结构的区别&哈希表&队列集合&栈集合&函数
类和结构的区别 类: 类是引用类型在堆上分配,类的实例进行赋值只是复制了引用,都指向同一段实际对象分配的内存 类有构造和析构函数 类可以继承和被继承 结构: 结构是值类型在栈上分配(虽然栈的访问速度比 ...
- [LeetCode]29. Divide Two Integers两数相除
Given two integers dividend and divisor, divide two integers without using multiplication, division ...