ZCMU 2177 Lucky Numbers (easy)
传送门:
http://acm.zcmu.edu.cn/JudgeOnline/problem.php?id=2177
2177: Lucky Numbers (easy)
时间限制: 2 Sec 内存限制: 256 MB
提交: 42 解决: 21
[提交][状态][讨论版]
题目描述
2 seconds
256 megabytes
standard input
standard output
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. For example, numbers 47, 7744, 474477 are super lucky and 4, 744, 467 are not.
One day Petya came across a positive integer n. Help him to find the least super lucky number which is not less than n.
The only line contains a positive integer n (1≤n≤109). This number doesn't have leading zeroes.
Output the least super lucky number that is more than or equal to n.
Please, do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specificator.
4500
4747
47
47
题目意思:
为你大于等于n的第一个幸运数字是什么
幸运数字:该数字只由4和7组成,且4和7的个数相等
做法:
直接暴力打表(打了大概三分钟,GG)
code:
/*#include <stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include<algorithm>*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[]={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,};
/*bool f(LL x)
{
int c1=0,c2=0;
while(x)
{
int a=x%10;
if(a!=4&&a!=7)
return false;
if(a==4)
c1++;
if(a==7)
c2++;
x/=10;
}
if(c1==c2)
return true;
else
return false;
}*/
int main()
{
/* for(LL i=47;i<10000000000;i++)
{
if(f(i))
{
cout<<i<<',';
}
}
printf("\n*******\n");*/
LL n;
cin>>n;
for(int i=;;i++)
{
if(a[i]>=n)
{
cout<<a[i]<<endl;
break;
}
}
return ;
}
ZCMU 2177 Lucky Numbers (easy)的更多相关文章
- C - Lucky Numbers (easy)
Problem description Petya loves lucky numbers. Everybody knows that positive integers are lucky if t ...
- 题解 CF1428G Lucky Numbers (Easy Version and Hard Version)
这题没有压行就成 \(\texttt{Hard Version}\) 最短代码解了( 要知道这题那么 \(sb\) 就不啃 \(D\) 和 \(E\) 了. \(\texttt{Solution}\) ...
- HDU 5676 ztr loves lucky numbers (模拟)
ztr loves lucky numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/I Description ztr ...
- codeforces 630C Lucky Numbers
C. Lucky Numbers time limit per test 0.5 seconds memory limit per test 64 megabytes input standard i ...
- hdu 5676 ztr loves lucky numbers(dfs+离线)
Problem Description ztr loves lucky numbers. Everybody knows that positive integers are lucky if the ...
- codeforces 630C - Lucky Numbers 递推思路
630C - Lucky Numbers 题目大意: 给定数字位数,且这个数字只能由7和8组成,问有多少种组合的可能性 思路: 假设为1位,只有7和8:两位的时候,除了77,78,87,88之外还哇哦 ...
- hdu 5676 ztr loves lucky numbers 打表+二分
ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- hdu-5676 ztr loves lucky numbers(乱搞题)
题目链接: ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- Codeforces Round #160 (Div. 2)---A. Roma and Lucky Numbers
Roma and Lucky Numbers time limit per test 1 second memory limit per test 256 megabytes input standa ...
随机推荐
- java 自定义 LRU(最近最少使用)策略 实现 缓存机制
1. java提供了一个简单的方式实现LRU: LinkedHashMap 2. 自定义实现 LRU至少需要两个主要操作: 添加(add)和搜索(search) public class LRU ...
- 洛谷 P2469 [SDOI2010]星际竞速 解题报告
题目描述 10年一度的银河系赛车大赛又要开始了.作为全银河最盛大的活动之一,夺得这个项目的冠军无疑是很多人的梦想,来自杰森座α星的悠悠也是其中之一. 赛车大赛的赛场由N颗行星和M条双向星际航路构成,其 ...
- redhat系统下三种主要的软件包安装方法
1. 通过RPM软件包来安装 RPM(Redhat Package Management)标准的软件包,只需简单地输入命令“rpm -ivh filename.rpm”即可: 如果需要对已经安装的RP ...
- SQL-OVER与四种排名函数:ROW_NUMBER(),RANK(),DENSE_RANK(),NTILE()
1 SELECT orderid,custid,val, ROW_NUMBER() OVER(ORDER BY val) AS rownum, RANK() OVER(ORDER BY val) AS ...
- <Android 应用 之路> MPAndroidChart~ScatterChart
简介 MPAndroidChart是PhilJay大神给Android开发者带来的福利.MPAndroidChart是一个功能强大并且使用灵活的图表开源库,支持Android和IOS两种,这里我们暂时 ...
- Java中int与Integer的区别
转自https://www.cnblogs.com/guodongdidi/p/6953217.html import java.lang.Integer; public class intDemo{ ...
- C++笔记(1)----此运算符函数的参数太多
在VS2015中定义了这样一个类: #include<iostream> #include<vector> #include<string> using names ...
- 我的CSDN博客&Github地址
我的 CSDN 博客地址: https://blog.csdn.net/qq_40147863 Github 地址: https://github.com/xpwi
- 常用sql commands以及mysql问题解决日志
mysql workbench常用命令快捷键 ctrl+T ->创建新的sql query tab ctrl+shift+enter->执行当前的sql命令 https://dev.mys ...
- ExpressRoute 概述
使用 Azure ExpressRoute 可通过连接服务提供商所提供的专用连接,将本地网络扩展到 Azure 云.使用 ExpressRoute 可与 Azure云服务建立连接. 可以从任意位置之间 ...