关于一些初级ACM竞赛题目的分析和题解(八)
2 seconds
256 megabytes
standard input
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.
The single line contains integer y (1000 ≤ y ≤ 9000) — the year number.
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.
1987
2013
2013
2014
#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);}}
}
重点是怎么找出个十百千的数,找到就好了,
2 seconds
256 megabytes
standard input
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.
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.
Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).
40047
NO
7747774
YES
1000000000000000000
NO
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竞赛题目的分析和题解(八)相关推荐
- 关于一些初级ACM竞赛题目的分析和题解(二)。
关于一些初级ACM竞赛题目的分析和题解(二). 今天写了关于排序的题 中间有加号的复杂的一行字符 其次还有关于tolower函数的应用, 上题 ...
- 关于一些初级ACM竞赛题目的分析和题解(十)
关于一些初级ACM竞赛题目的分析和题解(十) 西面的题目是关于一些字母变换的,上题: A. Word time limit per test 2 seconds memory limit per te ...
- 关于一些初级ACM竞赛题目的分析和题解(六)。
关于一些初级ACM竞赛题目的分析和题解(六). 下面是关于一些关于数字判断的题,比较简单,先来看第一题: A. Lucky Division time limit per test 2 seconds ...
- PKU ACM/ICPC竞赛队最近八年比赛成绩
PKU ACM/ICPC竞赛队最近八年比赛成绩 (不含预选赛前十名以外) 竞赛名称 年度 获奖名次 学生姓名 备 注 第29届ACM国际 大学生程序设计竞赛 亚洲区预选赛 2004 北京赛区第4名 饶 ...
- 2019浙江ACM省赛部分题解-ABDEFGHIJK
太菜了,心态炸了.QAQ A-Vertices in the Pocket() 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?proble ...
- 华东交通大学2018年ACM双基程序设计大赛题解
华东交通大学2018年ACM"双基"程序设计竞赛 代码头多的都是标答Ctrl+c下来的,给自己挖个坟,回头有时间再填回去,不填回去就死在这里吧-- 传送门:https://ac.n ...
- ACM新生赛部分题解
2021级的ACM新生赛已经完结了,我就自己做出来的八道题整理一下题解,因为其他是真的不会. 链接:登录-专业IT笔试面试备考平台_牛客网 来源:牛客网 一.我们是冠军 7 日星期 777 的凌晨,7 ...
- 2021暨南大学轩辕杯ACM程序设计新生赛题解
title : 2021暨南大学轩辕杯ACM程序设计新生赛 date : 2021-12-12 tags : ACM,练习记录 author : Linno 题目链接:https://ac.nowco ...
- 2018年第十届ACM四川省省赛题解(10 / 11)
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 2018ACM四川省省赛 题目链接:https://www.oj.swust.edu.cn/probl ...
- 华东交通大学2017年ACM双基程序设计大赛题解
简单题 Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other) Total Submissio ...
最新文章
- python windows端口检测并杀死脚本
- 【算法入门】动态图展示 6 个常用的数据结构,一目了然!
- (转)Inno Setup入门(六)——在程序目录下创建文件夹
- 洛谷 - P2472 [SCOI2007]蜥蜴(最大流)
- JS中Null与Undefined的区别
- 跨服务器、跨数据库、多表联合查询
- 这个“达芬奇”不一般!它是美国医生的好帮手
- django 标签的使用
- 你已经长大了,寄几的日志要寄几处理
- 写个简单的chrome插件-京东商品历史价格查询
- swper实现分页器样式修改
- R语言ggplot2可视化:使用geom_step可视化阶梯图、阶梯线图、可视化分组阶梯线图、自定义填充不同分组的阶梯线图(filled geom_step)
- Ubuntu 18.04.3 双屏显示其中一个屏幕黑屏无法使用的问题 显卡驱动安装问题
- 如何压缩带有mdw安全文件机制和密码的的access数据库
- 软件 ce ee 含义和区别
- 索罗斯:国际银行家的金融黑客
- 舵机PWM信号转互斥继电器开关信号
- AnnotationAttributes
- 【Java中方法的使用】
- java 网页防止刷赞_李洋