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 ...
随机推荐
- 强悍的 vim —— 删除空行、删除注释以及加注释解注释
强悍的 vim -- 删除空行.删除注释以及加注释解注释 原文 https://blog.csdn.net/lanchunhui/article/details/51588198 1. 删除空行空行的 ...
- ctags 寻找方法定义处
ctags这个是vim的一个插件,它可以用来生成一个检索文件,里面保存有一些索引信息.例如,一些类跟方法.变量等的定义位置当我们对一个路径执行ctags -R的时候,就会自动生成一个ctags,然后我 ...
- 突破极限 解决大硬盘上安装Unix新思路
一.问题提出 硬盘越做越大,然我喜欢让我忧.10年前就遇到过在586电脑BIOS不认识超过8.4G容量硬盘的问题,以及Windows Nt操作系统不认大硬盘(容量超过8.4G)的问题,对于Linux ...
- hive load文件第一个字段为NULL
在hive中,通常须要载入外部数据源.load文件时.第一个字段会出现NULL. 比如: 1.运行load语句: LOAD DATA LOCAL INPATH 'test.txt' OVERWRITE ...
- 【MongoDB】mongodump and mongorestore of mogodb
The another tool will be mentioned in this blog, namely mongodump and mongorestore. General speaking ...
- OpenGL核心技术之混合技术
笔者介绍:姜雪伟,IT公司技术合伙人,IT高级讲师,CSDN社区专家,特邀编辑,畅销书作者.国家专利发明人;已出版书籍:<手把手教你架构3D游戏引擎>电子工业出版社和<Unity3D ...
- 利用淘宝ip库限制地区访问
https://sss.one/97.html 利用淘宝ip库限制地区访问 有些应用可能需要对某些地区的用户进行限制访问 在采用才此方法的时候,可以利用一些ip库对访问者的ip进行判断 淘宝ip库地址 ...
- golang sync.Cond
package main import ( "fmt" "sync" "time" ) func main() { wait := sync ...
- Spider_selenium
json模块 什么是json? javascript中的对象和数组 对象:{key:value}取值:对象名.key 数组:[...,...]取值:数组[索引值] 作用 json格式的字符串和Pyth ...
- CList 点击表头排序 (3)两种排序的第二种
在头两篇中介绍了CListCtrl::SortItems() 方法的使用和其中的一个排序方法,这篇介绍另一种方法 CList 点击表头排序 (1)SortItems函数 CList 点击表头排序 (2 ...