uva---(11549)CALCULATOR CONUNDRUM
Problem C
CALCULATOR CONUNDRUM
Alice got a hold of an old calculator that can display n digits. She was bored enough to come up with the following time waster.
She enters a number k then repeatedly squares it until the result overflows. When the result overflows, only the n most
significant digits are displayed on the screen and an error flag
appears. Alice can clear the error and continue squaring the displayed
number. She got bored by this soon enough, but wondered:
“Given n and k, what is the largest number I can get by wasting time in this manner?”
Program Input
The first line of the input contains an integer t (1 ≤ t ≤ 200), the number of test cases. Each test case contains two integers n (1 ≤ n ≤ 9) and k (0 ≤ k < 10n) where n is the number of digits this calculator can display k is the starting number.
Program Output
For each test case, print the maximum number that Alice can get by repeatedly squaring the starting number as described.
Sample Input & Output
INPUT
2
1 6
2 99
OUTPUT
9
99
模拟题:
题意就是一个数,然后一直平方,然后求在这个过程中最大的前n位:
代码:
#include<cstring>
#include<set>
#include<iostream>
using namespace std;
long long mod[]={,,,,,,,,,};
int main(){
int n,test;
long long k;
cin>>test;
while(test--){
cin>>n>>k;
while(k/mod[n]>){ //截取高位
k/=;
}
long long res=k;
set<long long>sac;
while(sac.count(k)==){
sac.insert(k);
k*=k;
while(k/mod[n]>){ //截取高位
k/=;
}
if(k>res)res=k;
}
cout<<res<<endl;
}
return ;
}
uva---(11549)CALCULATOR CONUNDRUM的更多相关文章
- Floyd判圈算法 UVA 11549 - Calculator Conundrum
题意:给定一个数k,每次计算k的平方,然后截取最高的n位,然后不断重复这两个步骤,问这样可以得到的最大的数是多少? Floyd判圈算法:这个算法用在循环问题中,例如这个题目中,在不断重复中,一定有一个 ...
- UVA 11549 CALCULATOR CONUNDRUM(Floyd判圈算法)
CALCULATOR CONUNDRUM Alice got a hold of an old calculator that can display n digits. She was bore ...
- Uva 11549 - Calculator Conundrum 找规律加map
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVA 11549 Calculator Conundrum (Floyd判圈算法)
题意:有个老式计算器,每次只能记住一个数字的前n位.现在输入一个整数k,然后反复平方,一直做下去,能得到的最大数是多少.例如,n=1,k=6,那么一次显示:6,3,9,1... 思路:这个题一定会出现 ...
- 【set&&sstream||floyed判环算法】【UVa 11549】Calculator Conundrum
CALCULATOR CONUNDRUM Alice got a hold of an old calculator that can display n digits. She was bored ...
- UVa 11549 计算器谜题(Floyd判圈算法)
https://vjudge.net/problem/UVA-11549 题意: 有一个老式计算器,只能显示n位数字,输入一个整数k,然后反复平方,如果溢出的话,计算器会显示结果的最高n位.如果一直这 ...
- UVa 11549 Open Credit System
题意:给出n个数,找出两个整数a[i],a[j](i < j),使得a[i] - a[j]尽量大 从小到大枚举j,在这个过程中维护a[i]的最大值 maxai晚于ans更新, 可以看这个例子 1 ...
- [UVa11549]Calculator Conundrum
题目大意:有一个只能显示n位数字的计算器,当溢出时只显示最高的n位. 输入k,要你不断平方,问你计算器显示的最大数是多少. 解题思路:这题的示数肯定会循环,那么我们关键就是找什么时候循环了. 可以用F ...
- 【图论】Floyd消圈算法
毫无卵用的百度百科 Definition&Solution 对于一个给定的链表,如何判定它是否存在环以及环的长度问题,可以使用Floyd消圈算法求出. 从某种意义上来讲,带环的链表在本质上是一 ...
随机推荐
- axis2通过wsdl生成客户端程序并本地调用
wsdl2java -uri http://10.0.5.12/brm/services/RuleEngine1374389539674484?wsdl -p east.mvc.webservice. ...
- CodeForces 42A Guilty — to the kitchen!
Guilty — to the kitchen! Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- Windows Live Writer代码高亮插件对比
一.Paste ASVisual Studio Code 参考:http://www.cnblogs.com/mikelij/archive/2010/11/13/1876199.html 插件下载: ...
- CNV
CNV: 人类主要是二倍体.如果有些区域出现3个.4个拷贝,那就是扩增了,如果只出现1个拷贝,就是缺失.所以CNV分析是依靠特定位置的测序深度来估算的,先在染色体上划窗,然后看每个窗口的平均测序深度, ...
- CUBRID学习笔记 13 日志文件
欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com . 过错 CUBRID Broker Log Files 可以理解为数据库中间件日志 ...
- implement "slam_karto" package in Stage simulation
slam_karto ROS Wiki: http://wiki.ros.org/slam_karto Source: https://github.com/ros-perception/slam_k ...
- hnoi 2016 省选总结
感觉省选好难的说...反正我数据结构太垃圾正解想到了也打不出来打一打暴力就滚粗了! DAY1 0+20+30 DAY2 60-20+0+60 最后170-20分,暴力分还是没有拿全! 然而这次是给了5 ...
- Intel微处理器学习笔记(五) 中断
▼ 中断是一个由硬件激发的过程,它中断当前正在执行的任何程序. ▼ 在Intel系列微处理器中,包括INTR和NMI(Non Maskable Interrupt)两个申请中断的引脚和一个响应INTR ...
- Tomcat配置虚拟目录
在Tomcat7版本下,配置虚拟路径修改以下两个文件: 1.server.xml 打开Tomcat目录下的/conf/server.xml文件,在Host之前加入下面红色部分的内容. ...
- Windows Live Writer配置
Windows Live Writer手工配置步骤: 1.在菜单中选择"Weblog";,然后选择"Another Weblog Service". 2.在We ...