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. tp5 auth权限的原理

    我的一些个人理解,还是有些不懂的地方,有错误请指正,谢谢!!! class Auth{ //默认配置 protected $_config = array( 'auth_on' => true, ...

  2. How to check if directory exist using C++ and winAPI

    如果看文件夹是否存在,必须看返回值是不是 INVALID_FILE_ATTRIBUTES #include <windows.h> #include <string> bool ...

  3. Ubuntu parted 命令 写在脚本里时要带 -s 参数

    否则会要求用户输入,造成脚本卡住.

  4. c++中set 的用法

    1.关于set C++ STL 之所以得到广泛的赞誉,也被很多人使用,不只是提供了像vector, string, list等方便的容器,更重要的是STL封装了许多复杂的数据结构算法和大量常用数据结构 ...

  5. JDK14的新特性:Lombok的终结者record

    目录 简介 新的Record类型 探讨Record的秘密 record扩展 总结 JDK 14的新特性:Lombok的终结者record 简介 自从面向对象产生之后,程序界就开始了新的变化,先是C发展 ...

  6. java基础问题 (待解决)

    (1)接口与抽象类的区别? (2)Java中的异常有哪几类?分别怎么使用? (3)常用的集合类有哪些?比如List如何排序? (4)ArrayList和LinkedList内部的实现大致是怎样的?他们 ...

  7. 中国AI觉醒 阿里王坚:云智能将成为大趋势

    2019独角兽企业重金招聘Python工程师标准>>> <麻省理工科技评论>新兴科技峰会EmTech China于北京召开.大会中,其中一项热门的讨论便是:中国和美国的科 ...

  8. Codeforces 1291 Round #616 (Div. 2) B

    B. Array Sharpening time limit per test1 second memory limit per test256 megabytes inputstandard inp ...

  9. Unix的I/O模型

    对于一次I/O操作(以read为例),数据首先被拷贝到内核的某个缓冲区,然后再从内核缓冲区拷贝到应用进程缓冲区. 因此,一次I/O操作通常包含两个阶段: (1) 等待数据准备好 (2) 从内核向进程复 ...

  10. spring学习笔记(七)HttpMessageConverter

    spring学习笔记(七)HttpMessageConverter 1. HttpMessageConverter的加载 2. 从StringMessageConverter探究消息转换器的原理 1. ...