Lucky 7 in the Pocket
Time Limit: 1 Second Memory Limit: 65536 KB
BaoBao loves number 7 but hates number 4, so he refers to an integer x as a “lucky integer” if x is divisible by 7 but not divisible by 4. For example, 7, 14 and 21 are lucky integers, but 1, 4 and 28 are not.
Today BaoBao has just found an integer n in his left pocket. As BaoBao dislikes large integers, he decides to find a lucky integer m such that m≥m and is as small as possible. Please help BaoBao calculate the value of m.
Input
There are multiple test cases. The first line of the input is an integer T (about 100), indicating the number of test cases. For each test case:
The first and only line contains an integer n(1≤n≤100), indicating the integer in BaoBao’s left pocket.
Output
For each test case output one line containing one integer, indicating the value of .
Sample Input
4
1
7
20
28
Sample Output
7
7
21
35
解析:
题目的意思就是输出一个能被7整除不能被4整除而且要大于等于输入
#include<stdio.h>
int main(){
int T,n;
scanf("%d",&T);
for(int i=1;i<=T;i++){
scanf("%d",&n);
for(int j=n;1;j++){
if(j%7==0 && j%4!=0){
printf("%d\n",j);
break;
}
}
}
return 0;
}