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. php表格--大数据处理

    参考来源1:https://blog.csdn.net/tim_phper/article/details/77581071 参考来源2:https://blog.csdn.net/qq_376822 ...

  2. php二维数组的排序

    /**  * @desc arraySort php二维数组排序 按照指定的key 对数组进行排序  * @param array $arr 将要排序的数组  * @param string $key ...

  3. 2019-2020-1 20199329《Linux内核原理与分析》第七周作业

    <Linux内核原理与分析>第七周作业 一.本周内容概述: 对Linux系统如何创建一个新进程进行追踪 分析Linux内核创建一个新进程的过程 二.本周学习内容: 1.学习进程的描述 操作 ...

  4. Session服务器之Redis

    Session服务器之Redis Redis与Memcached的区别内存利用率:使用简单的key value (键值对)存储的话,Mermcached 的内存利用率更高,而如果Redis采用hash ...

  5. 再也不用c刷题了!!——c++刷题必备

    致读者: 博主是一名数据科学与大数据专业大二的学生,真正的一个互联网萌新,写博客一方面是为了记录自己的学习历程,一方面是希望能够帮助到很多和自己一样处于困惑的读者.由于水平有限,博客中难免会有一些错误 ...

  6. div/dom元素拖拽缩放插件,纯js实现拖拽缩放,不依赖jQuery~

    产品需求,需要用到对div(dom)进行拖拽缩放操作,看到有好多插件,要么依赖jQuery,要么文件太大. 封装了一个插件,不压缩状态下5KB. html <!DOCTYPE html> ...

  7. 《C Primer Plus(第6版)中文版》一1.12 复习题

    本节书摘来自异步社区<C Primer Plus(第6版)中文版>一书中的第1章,第1.12节,作者 傅道坤,更多章节内容可以访问云栖社区"异步社区"公众号查看. 1. ...

  8. JeeSite 4.0 简化业务逻辑层开发

    2019独角兽企业重金招聘Python工程师标准>>> 引言 对于业务逻辑层的开发重复代码很多,尽管有代码生成器,但从代码量总的来说还是比较多,所以就有了以下抽象类及工具,对一些常用 ...

  9. bfs—Catch That Cow—poj3278

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 87152   Accepted: 27344 ...

  10. HTML5 Canvas指纹及反追踪介绍

    1 Canvas指纹的简介很多网站通过Canvas指纹来跟踪用户.browserleaks[1]是一个在线检测canvas指纹的网站.一般的指纹实现原理即通过canvas画布绘制一些图形,填写一些文字 ...