**C - Lucky 7 in the Pocket **

BaoBao loves number 7 but hates number 4, so he refers to an integer as a "lucky integer" if 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 in his left pocket. As BaoBao dislikes large integers, he decides to find a lucky integer such that and is as small as possible. Please help BaoBao calculate the value of .

Input

There are multiple test cases. The first line of the input is an integer (about 100), indicating the number of test cases. For each test case:

The first and only line contains an integer (), 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

正确代码

	#include <iostream>  

	using namespace std;  

	int a[1000];  

	int main(){
for (int i = 1; i < 1000; ++i) {
if(i%7==0&&i%4!=0){
a[i]=1;
}
}
int T;
cin>>T;
while (T--){
int n;
cin>>n;
for (int i = n; i < 1000; ++i) {
if(a[i]==1){
cout<<i<<endl;
break;
}
}
}
return 0;
}

题意理解

首先,题意规定了n的取值范围,因为取值范围足够小,仅仅在1-100之间,因此我选择使用预处理即计算1-1000之内所有可以被7整除而不能被4整除的数,接着用for循环进行查找数据得出。

最新文章

  1. 【HTML5&amp;CSS3进阶学习02】Header的实现&#183;CSS中的布局
  2. 搜索技巧&lt;转&gt;
  3. Linux查看进程PID信息
  4. 技海拾贝 - Java
  5. i++与++i 辨析
  6. python通过163邮箱发送邮件
  7. (剑指Offer)面试题22:栈的压入、弹出序列
  8. [原创] zabbix学习之旅三:agent安装
  9. exercise.tour.go google的go官方教程答案
  10. 利用内存结构及多线程优化多图片下载(IOS篇)
  11. ASP.NET MVC 5 学习教程:生成的代码详解
  12. crawler_phantomjs_windows_linux下demo
  13. 微信公众号开发之网页中及时获取当前用户Openid及注意事项
  14. Chapter 2 Open Book——6
  15. css层叠样式表
  16. Django之form表单
  17. combox的基本应用
  18. js加减法运算多出很多小数点
  19. 鸟哥的Linux私房菜——第十九章:例行命令的建立
  20. dpkg: warning: files list file for package `*****&#39; missing, assuming package has no files currently installed解决办法

热门文章

  1. JavaScript中匿名函数this指向问题
  2. Vivado debug异常现象
  3. Redis 学习-持久化与主从复制
  4. tcpdump截帧工具使用
  5. 【转】关于TCP/IP,必须知道的十个知识点
  6. thinkphp概述2
  7. 通过visual studio制作类库的文档
  8. P,R,F1 等性能度量(二分类、多分类)
  9. java中List与数组的转换
  10. 远程连接Linux mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决方法