传送门:

http://acm.zcmu.edu.cn/JudgeOnline/problem.php?id=2177

2177: Lucky Numbers (easy)

时间限制: 2 Sec  内存限制: 256 MB
提交: 42  解决: 21
[提交][状态][讨论版]

题目描述

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

The only line contains a positive integer n (1≤n≤109). This number doesn't have leading zeroes.

Output

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.

Examples
Input
4500
Output
4747
Input
47
Output
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)的更多相关文章

  1. C - Lucky Numbers (easy)

    Problem description Petya loves lucky numbers. Everybody knows that positive integers are lucky if t ...

  2. 题解 CF1428G Lucky Numbers (Easy Version and Hard Version)

    这题没有压行就成 \(\texttt{Hard Version}\) 最短代码解了( 要知道这题那么 \(sb\) 就不啃 \(D\) 和 \(E\) 了. \(\texttt{Solution}\) ...

  3. HDU 5676 ztr loves lucky numbers (模拟)

    ztr loves lucky numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/I Description ztr ...

  4. codeforces 630C Lucky Numbers

    C. Lucky Numbers time limit per test 0.5 seconds memory limit per test 64 megabytes input standard i ...

  5. hdu 5676 ztr loves lucky numbers(dfs+离线)

    Problem Description ztr loves lucky numbers. Everybody knows that positive integers are lucky if the ...

  6. codeforces 630C - Lucky Numbers 递推思路

    630C - Lucky Numbers 题目大意: 给定数字位数,且这个数字只能由7和8组成,问有多少种组合的可能性 思路: 假设为1位,只有7和8:两位的时候,除了77,78,87,88之外还哇哦 ...

  7. hdu 5676 ztr loves lucky numbers 打表+二分

    ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/ ...

  8. hdu-5676 ztr loves lucky numbers(乱搞题)

    题目链接: ztr loves lucky numbers  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K ( ...

  9. 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 ...

随机推荐

  1. HDU 2199 (二分法)

    主要思想就是两端逼近,最后得到结果,0MS #include <iostream> #include <cstdlib> #include <cstdio> #in ...

  2. Oracle数据库基本操作 (五) —— 使用java调用存储过程

    一.环境准备 登录Oracle数据库scott账号,利用emp进行操作. 1.创建 proc_getyearsal 存储过程 -- 获取指定员工年薪 create or replace procedu ...

  3. JS 和 a href className JS编写顺序与运行顺序 字符串或变量嵌入中括号 代替 点号 代表属性

    JS 和 a href 在href里面注意分号结尾, 引号闭合 <a href="javascript:;">空链接</a> <a href=&quo ...

  4. Spring Data MongoDB 环境搭建

    一.开发环境 spring版本:4.0.6.RELEASE spring-data-mongodb版本:1.4.1.RELEASE junit版本 4.11 maven版本:3.0.5 二.pom.x ...

  5. <Android 基础(二十四)> EditText

    介绍 A text field allows the user to type text into your app. It can be either single line or multi-li ...

  6. Android ImageSpan的使用

    编辑框中加图片 代码如下: mSubjectDetailView = (TextView) findViewById(R.id.subject_detail); CharSequence text = ...

  7. The parameter to the method is the basic data type

    package method.invocation; public class TheParameterToTheMethodIsTheBasicDataType { public static vo ...

  8. TCP协议 状态解析和状态统计

    一.三次握手和四次挥手 1.建立连接(三次握手)   (1)服务器会处于listen状态,客户端发送一个带SYN标志的TCP报文到服务器.   (2)服务器端回应客户端的请求,这是三次握手中的第2个报 ...

  9. mysql索引小记

    Mysql索引分为以下几类:FULLTEXT, HASH,BTREE,RTREE. FULLTEXT:全文搜索索引 主要是解决'ad%'这样的查询效率低的问题,只能是MyISAM和InnoDB引擎上使 ...

  10. SQL Server Mobile/Compact Edition 简单介绍

    除了SQL Server Express,SQL Server还有个更轻量级的版本:SQL Server Compact Edition,容易让人想起Windows Compact Edition ( ...