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 ...
随机推荐
- C#学习笔记-继承基本知识
namespace Inheritance { class Program { static void Main(string[] args) { Dog dog = new Dog(); dog.A ...
- iview-admin2中vue.config配置文件輸出路徑
在vue.config.js文件中添加如下信息 module.exports = { baseUrl: '', // 可以配置生产和测试环境下,文件的路径(即index中引用的路径,但不会在dist中 ...
- 使用postMessage通信,未触发message事件
前提: 父子页面跨域通信,使用postMessage技术 a页面为父页面,b页面为子页面 a中包含多个iframe,部分域名是相同的,目录层级不一致,地址使用变量根据触发的条件不同拼接地址 部分代码( ...
- 使用PermissionsDispatcher轻松解决Android权限问题
之前也处理过6.0后的权限问题,直接处理很是麻烦.这次在github上搜到了关于权限星数最多的PermissionsDispatcher这个库,几个注释完美解决权限问题. 第一步 添加各种注释 1.@ ...
- Ajax的初体验
一.AJAX的介绍 Ajax 即“Asynchronous Javascript And XML”(异步 JavaScript 和 XML),是指一种创建交互式网页应用的网页开发技术. Ajax = ...
- CSS技巧教程:margin在IE中的表现
margin的位移方向是指margin数值为正值时候的情形,如果是负值则位移方向相反. 如上图所示:黄色子元素盒的margin-top,margin-left为负值时,如-10px,则黄色子元素盒向上 ...
- java基础问题解答
Java学习中的问题 一 枚举类型: 下面是一段源程序代码: package Demo; public class Enum { public static void main(String[] ...
- 大数据实时计算工程师/Hadoop工程师/数据分析师职业路线图
http://edu.51cto.com/roadmap/view/id-29.html http://my.oschina.net/infiniteSpace/blog/308401 大数据实时计算 ...
- Python学习---Python的框架基础学习
框架基础 框架实质: 所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端 B/S结构的响应: import socket def handle_requ ...
- Java学习---MD5加密算法
前言 在我们日常的程序开发中,或多或少会遇到一些加密/解密的场景,比如在一些接口调用的过程中,我们(Client)不仅仅需要传递给接口服务(Server)必要的业务参数,还得提供Signature(数 ...