关于一些初级ACM竞赛题目的分析和题解(八) 
下面两道题只是表面上复杂些而已,其实比较简单,上题:
A. Beautiful Year
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.

Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.

Input

The single line contains integer y (1000 ≤ y ≤ 9000) — the year number.

Output

Print a single integer — the minimum year number that is strictly larger than y and all it's digits are distinct. It is guaranteed that the answer exists.

Examples
input
1987

output
2013

input
2013

output
2014

输入n(n大于等于1000,小于等于9000,且n的个十百千位各不相同),找出比n大的并个十百千位也不同的数;
下面是代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{int a,b,c,d,e,n;scanf("%d",&n);while (n<=10000){
n++;a=n%10;b=n%100/10;c=n/1000;d=n%1000/100;  // 确定个十百千位if (a!=b&&a!=c&&a!=d&&b!=c&&b!=d&&c!=d)  //  判断各位不同{  return 0*printf("%d",n);}}
}

重点是怎么找出个十百千的数,找到就好了,

A. Nearly Lucky Number
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.

Input

The only line contains an integer n (1 ≤ n ≤ 1018).

Please do not use the %lld specificator to read or write 64-bit numbers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.

Output

Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).

Examples
input
40047

output
NO

input
7747774

output
YES

input
1000000000000000000

output
NO

Note

In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".

In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".

In the third sample there are no lucky digits, so the answer is "NO".

关于幸运数,输入一行数,若他的各位数含4,7的数为4和7则为几乎幸运的数,判断是否为几乎幸运的数,是的话输出YES,否的话输出NO,下面是代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{int l,b=0;char a[19999];gets(a);l=strlen(a);for (int i=0;i<l;i++)if(a[i]=='4'||a[i]=='7')b++;   // 计数printf((b==4||b==7)?"YES":"NO");}

这两道题都比较简单,多练A题也能学到c++语言的一些语法。希望自己能越学越好

关于一些初级ACM竞赛题目的分析和题解(八)相关推荐

  1. 关于一些初级ACM竞赛题目的分析和题解(二)。

    关于一些初级ACM竞赛题目的分析和题解(二). 今天写了关于排序的题  中间有加号的复杂的一行字符   其次还有关于tolower函数的应用, 上题                           ...

  2. 关于一些初级ACM竞赛题目的分析和题解(十)

    关于一些初级ACM竞赛题目的分析和题解(十) 西面的题目是关于一些字母变换的,上题: A. Word time limit per test 2 seconds memory limit per te ...

  3. 关于一些初级ACM竞赛题目的分析和题解(六)。

    关于一些初级ACM竞赛题目的分析和题解(六). 下面是关于一些关于数字判断的题,比较简单,先来看第一题: A. Lucky Division time limit per test 2 seconds ...

  4. PKU ACM/ICPC竞赛队最近八年比赛成绩

    PKU ACM/ICPC竞赛队最近八年比赛成绩 (不含预选赛前十名以外) 竞赛名称 年度 获奖名次 学生姓名 备 注 第29届ACM国际 大学生程序设计竞赛 亚洲区预选赛 2004 北京赛区第4名 饶 ...

  5. 2019浙江ACM省赛部分题解-ABDEFGHIJK

    太菜了,心态炸了.QAQ A-Vertices in the Pocket() 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?proble ...

  6. 华东交通大学2018年ACM双基程序设计大赛题解

    华东交通大学2018年ACM"双基"程序设计竞赛 代码头多的都是标答Ctrl+c下来的,给自己挖个坟,回头有时间再填回去,不填回去就死在这里吧-- 传送门:https://ac.n ...

  7. ACM新生赛部分题解

    2021级的ACM新生赛已经完结了,我就自己做出来的八道题整理一下题解,因为其他是真的不会. 链接:登录-专业IT笔试面试备考平台_牛客网 来源:牛客网 一.我们是冠军 7 日星期 777 的凌晨,7 ...

  8. 2021暨南大学轩辕杯ACM程序设计新生赛题解

    title : 2021暨南大学轩辕杯ACM程序设计新生赛 date : 2021-12-12 tags : ACM,练习记录 author : Linno 题目链接:https://ac.nowco ...

  9. 2018年第十届ACM四川省省赛题解(10 / 11)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 2018ACM四川省省赛 题目链接:https://www.oj.swust.edu.cn/probl ...

  10. 华东交通大学2017年ACM双基程序设计大赛题解

    简单题 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Submissio ...

最新文章

  1. python windows端口检测并杀死脚本
  2. 【算法入门】动态图展示 6 个常用的数据结构,一目了然!
  3. (转)Inno Setup入门(六)——在程序目录下创建文件夹
  4. 洛谷 - P2472 [SCOI2007]蜥蜴(最大流)
  5. JS中Null与Undefined的区别
  6. 跨服务器、跨数据库、多表联合查询
  7. 这个“达芬奇”不一般!它是美国医生的好帮手
  8. django 标签的使用
  9. 你已经长大了,寄几的日志要寄几处理
  10. 写个简单的chrome插件-京东商品历史价格查询
  11. swper实现分页器样式修改
  12. R语言ggplot2可视化:使用geom_step可视化阶梯图、阶梯线图、可视化分组阶梯线图、自定义填充不同分组的阶梯线图(filled geom_step)
  13. Ubuntu 18.04.3 双屏显示其中一个屏幕黑屏无法使用的问题 显卡驱动安装问题
  14. 如何压缩带有mdw安全文件机制和密码的的access数据库
  15. 软件 ce ee 含义和区别
  16. 索罗斯:国际银行家的金融黑客
  17. 舵机PWM信号转互斥继电器开关信号
  18. AnnotationAttributes
  19. 【Java中方法的使用】
  20. java 网页防止刷赞_李洋

热门文章

  1. Ubuntu 20.04 Install Navicat
  2. 基于java springboot 活动报名微信小程序源码
  3. 王道训练营Day24——Linked
  4. window版本下载安装kafka和ZooKeeper并调试
  5. 杰理AD14N/AD15N---长按键开关机怎么实现
  6. 在Linux系统中重现黑客帝国经典画面
  7. 简单的mock-server 解决方案
  8. S变换介绍(附代码)
  9. 白盒测试实验报告模板
  10. 计算机网络技术思维导图幕布全整理(附网页版链接)