Polycarp knows that if the sum of the digits of a number is divisible by 3, then the number itself is divisible by 3. He assumes that the numbers, the sum of the digits of which is divisible by 4, are also somewhat interesting. Thus, he considers a positive integer n interesting if its sum of digits is divisible by 4.

Help Polycarp find the nearest larger or equal interesting number for the given number a. That is, find the interesting number nn such that n≥a and n is minimal.

Input

The only line in the input contains an integer a (1≤a≤1000).

Output

Print the nearest greater or equal interesting number for the given number aa. In other words, print the interesting number nn such that n≥a and n is minimal.

 #include<iostream>
using namespace std;
int main() {
int a,n,sum=,i;
cin>>a;
for(i=a; i<=; i++) {
int b=i;
while(b) {
int t=b%;
b=b/;
sum+=t;
}
if(sum%==) {
cout<<i;
i=;
}
sum=;
}
}

思路分析:输入一个数a,将它从a递增来获得它的最小的各位数和能整出4的整数。先求个十百千位数之和,如果和能整除4就输出这个数。进行取余和取模运算。

Codeforces1183A(A题)Nearest Interesting Number的更多相关文章

  1. Nearest Interesting Number

    Polycarp knows that if the sum of the digits of a number is divisible by 33, then the number itself ...

  2. Codeforces 1183A Nearest Interesting Number

    题目链接:http://codeforces.com/problemset/problem/1183/A 题意:求不小于 a 且每位数和能被 4 整除的 最小 n 思路:暴力模拟就好. AC代码: # ...

  3. lintcode 中等题:majority number III主元素III

    题目 主元素 III 给定一个整型数组,找到主元素,它在数组中的出现次数严格大于数组元素个数的1/k. 样例 ,返回 3 注意 数组中只有唯一的主元素 挑战 要求时间复杂度为O(n),空间复杂度为O( ...

  4. 湖南省第六届大学生程序设计大赛原题 F Biggest Number (UVA1182)

    Biggest Number http://acm.hust.edu.cn/vjudge/contest/view.action?cid=30851#problem/F 解题思路:DFS(检索)+BF ...

  5. 【LeetCode每天一题】Fibonacci Number(斐波那契数列)

    The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such th ...

  6. leetcode-【简单题】Happy Number

    题目: Write an algorithm to determine if a number is "happy". A happy number is a number def ...

  7. [UCSD白板题 ]Small Fibonacci Number

    Problem Introduction The Fibonacci numbers are defined as follows: \(F_0=0\), \(F_1=1\),and \(F_i=F_ ...

  8. lintcode 中等题:Majority number II 主元素 II

    题目 主元素II 给定一个整型数组,找到主元素,它在数组中的出现次数严格大于数组元素个数的三分之一. 样例 给出数组[1,2,1,2,1,3,3] 返回 1 注意 数组中只有唯一的主元素 挑战 要求时 ...

  9. LeetCode算法题-Reach a Number(Java实现)

    这是悦乐书的第310次更新,第331篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第179题(顺位题号是754).你站在无限数字线的0号位置.在目的地有个target.在 ...

随机推荐

  1. 0day学习笔记(3)Windows定位API引起的惨案(原理)

    段选择器FS与TEB WinNT内核下内存采用保护模式,段寄存器的意义与实模式汇编下的意义不同.另外,FS存的是段选择子,而不是实模式下的高16位基地址. FS寄存器指向当前活动线程的TEB结构(线程 ...

  2. css中的宽和高

    width width表示宽 height height表示高 max-width.min-width max-width表示最大宽度 min-width表示最小宽度 max-height.min-h ...

  3. js之 DOM与BOM

    JavaScript HTML DOM (文档对象模型)(Document Object Model) 什么是DOM? DOM是W3C标准. DOM定义了访问文档的标准: “W3C文档对象模型(DOM ...

  4. vue2.x学习笔记(二十七)

    接着前面的内容:https://www.cnblogs.com/yanggb/p/12682364.html. 单元测试 vue cli拥有开箱即用的通过jest或mocha进行单元测试的内置选项.官 ...

  5. C6 C7的开机启动流程

    C6开机启动流程 1.内核引导,加电自检(通电后检查内核):检查bios的配置,检测硬件 装好系统之后才会进行以下内容 MBR 引导 (3.2.1...) GRUB菜单 (选择不同的系统)(按e,进入 ...

  6. [软件共享]将数据库中的数据导出为SQL脚本

    可以直接将数据库中的数据导出为脚本,并可以自己设置过滤条件.使用方法很简单,不在多说了.下面是软件截图.123 下载:http://files.cnblogs.com/pw/mssql2.rar

  7. log4j 详细解释

    2019独角兽企业重金招聘Python工程师标准>>> 虽然说log4j自己会用,但是还是觉得对配置文件还不是很熟悉,最近看了一个博客,感觉很不多,我提炼出自己的理解. 地址 案例我 ...

  8. ubuntu 14.04安装pycharm 社区版

    https://blog.csdn.net/u013733432/article/details/54425831 转载于:https://www.cnblogs.com/liu-shiliu/p/1 ...

  9. 关于LinearLayout设置权重后width或height不设置0dp的影响说明

    摘要 平时没那么注意LinearLayout布局时权重的问题,设置了权重属性后,通常建议将width或height的属性值设置为0dp,有时候设置权重后,还是习惯将width或height的属性设置为 ...

  10. Nacos作为配置中心时,多个服务共用一个dataId的配置

    写在前面 本文是对我之前一篇文章<Spring Cloud+nacos+Feign,实现注册中心及配置中心>的补充.此文章中简单写了如何将Nacos作为配置中心.在使用配置中心时,我们会遇 ...