关于一些初级ACM竞赛题目的分析和题解(六)。
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
47
YES
16
YES
78
NO
Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int a;
scanf("%d",&a);
printf(a%4==0||a%7==0||a%47==0||a%74==0||a%447==0||a%477==0||a%474==0?"YES":"NO"); //判断 并输出
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b,c,d,e;
int main()
{
cin>>a; // 输入n
while (a--) // 再输入n行
{
cin>>b>>c; // 输入两个数
if(c>=b+2)
d++;
}
printf("%d",d);
}
上面的题略有些骚操作
printf(a%4==0||a%7==0||a%47==0||a%74==0||a%447==0||a%477==0||a%474==0?"YES":"NO");
1.scanf大概用的最多的了,比较方便,2.gets 和 puts这一对是用于数组的。
int a,b=0;
cin>>a>>b; //输入a,b
cout<<a<<b; //输出a,b
char a[100];
gets (a); // 输入a数组
puts (a); //输出a数组
int a=0;
scanf("%d",&a); // 输入a
printf("%d",a); //输出b