ZOJ 2679 Old Bill ||ZOJ 2952 Find All M^N Please 两题水题
2679:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1679
2952:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1951
ZOJ:2679先来~
水题大意:(题目大意:我什么时候改名了哇T T)
给你一个5位数的中间三个字母,还有一个数N让你求能被N整除的最大的五位数。
思路:
直接暴力枚举。。。。
#include<cstdio>
int num[6];
int main()
{
int T,n;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
scanf("%d%d%d",&num[2],&num[3],&num[4]);
bool ok=false;
for(int x=9;x>=1;x--)
{
num[1]=x;
for(int k=9;k>=0;k--)
{
num[5]=k;
int t=1,ans=0;
for(int i=5;i>=1;i--,t*=10)
ans=ans+ num[i]*t;
if(ans % n ==0)
{
ok=true;
printf("%d %d %d\n",x,k,ans/n);
goto end;
}
}
}
end:;
if(!ok)
printf("0\n"); }
return 0;
}
ZOJ : 2952
水题大意:
找出所有小于2^31能被表示为n ^m的数。
思路:
传说中的打表。
用long long 防乘法的时候直接越界了。
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL N=2147483648;
const int MAXN=50000;
int len=0;
LL ans[MAXN];
int main()
{ for(LL i=2;i*i<=N;i++)
{
LL temp=i;
while(true)
{
temp=temp*i;
if(temp>=N)
break;
ans[len++]=temp;
}
}
sort(ans,ans+len);
printf("%d\n",ans[0]);
for(int i=1;i<len;i++)
if(ans[i]!=ans[i-1])
printf("%lld\n",ans[i]);
return 0;
}
ZOJ 2679 Old Bill ||ZOJ 2952 Find All M^N Please 两题水题的更多相关文章
- ZOJ 2679 Old Bill(数学)
主题链接:problemCode=2679" target="_blank">http://acm.zju.edu.cn/onlinejudge/showProbl ...
- zoj 2679 Old Bill
Old Bill Time Limit: 2 Seconds Memory Limit: 65536 KB Among grandfather��s papers a bill was fo ...
- ZOJ 2819 Average Score 牡丹江现场赛A题 水题/签到题
ZOJ 2819 Average Score Time Limit: 2 Sec Memory Limit: 60 MB 题目连接 http://acm.zju.edu.cn/onlinejudge ...
- 水题 ZOJ 3875 Lunch Time
题目传送门 /* 水题:找排序找中间的价格,若有两个,选价格大的: 写的是有点搓:) */ #include <cstdio> #include <iostream> #inc ...
- 水题 ZOJ 3876 May Day Holiday
题目传送门 /* 水题:已知1928年1月1日是星期日,若是闰年加1,总天数对7取余判断就好了: */ #include <cstdio> #include <iostream> ...
- 水题 ZOJ 3880 Demacia of the Ancients
题目传送门 /* 水题:) */ #include <cstdio> #include <iostream> #include <algorithm> #inclu ...
- [ACM_水题] ZOJ 3706 [Break Standard Weight 砝码拆分,可称质量种类,暴力]
The balance was the first mass measuring instrument invented. In its traditional form, it consists o ...
- [ACM_水题] ZOJ 3714 [Java Beans 环中连续m个数最大值]
There are N little kids sitting in a circle, each of them are carrying some java beans in their hand ...
- [ACM_水题] ZOJ 3712 [Hard to Play 300 100 50 最大最小]
MightyHorse is playing a music game called osu!. After playing for several months, MightyHorse disco ...
随机推荐
- Android自己定义效果——随机抽奖
那天逛android开源码的时候,看到一个wheel menu的自己定义效果,就是类似人家的那种转盘抽奖,把人家project看了下.认为非常好玩.可是不想在他上面改,于是就自己想了一个类似的随即抽奖 ...
- Linq案例
1.牛刀小试 using System; using System.Collections.Generic; using System.Linq; using System.Text; using S ...
- Scott Hanselman的问题-3
.Net程序员面试 中级篇 (回答Scott Hanselman的问题) 继<.Net 程序员面试 C# 语言篇 (回答Scott Hanselman的问题)>跟<.Net程序员 ...
- XML与JSON的区别?各自有哪些优缺点?
JSON和XML都是数据传输格式,它们有哪些区别,又都有些什么优缺点呢?零度带领大家来分析分析. 一.先来看看两者的定义 1.XML的定义 扩展标记语言 (Extensible Markup Lang ...
- 14.字符串hash寻找第一个只出现一次的字符
//char 0-255一共256个 char getonebyhash(char *str) { if (str == NULL) { return '\0'; } char ch = '\0'; ...
- 运动识别之HOJ3D和HMM
http://cvrc.ece.utexas.edu/Publications/Xia_HAU3D12.pdf View Invariant Human Action Recognition Us ...
- px、em、rem、vw、vh、vm、rpx这些单位的
px是像素 em是参考父元素的font-size的倍数 rem是参考根元素的font-size 常用于响应式,一般会让html的font-size:625%,body的大小为.16rem.这样1rem ...
- kali之Nmap (Network Mapper(网络映射器)
Nmap是主机扫描工具,他的图形化界面是Zenmap,分布式框架为Dnamp. Nmap可以完成以下任务: 主机探测 端口扫描 版本检测 系统检测 支持探测脚本的编写 Nmap在实际中应用场合如下: ...
- ubuntu-虚拟机分辨率设定
前两天下载的虚拟机,一直调节不好分辨率,就是说,全屏的时候,虚拟机要么是不能充满屏幕,要么就是在屏幕充满的时候,会出现显示不全,需要滚动条,给人的体验非常的不好.自己调节了好长时间都没有刚好合适的尺寸 ...
- CISP/CISA 每日一题 三
CISA 每日一题(答) 测试应用控制的有效性包括: 分析计算机应用程序.测试计算机应用程序控制.选择和监控数据处理事务. 测试应用系统技术: 快照.映射.追踪和标识.测试数据(在真实的系统中的仿真交 ...