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. 《JAVA8开发指南》使用流式操作

    为什么需要流式操作 集合API是Java API中最重要的部分.基本上每一个java程序都离不开集合.尽管很重要,但是现有的集合处理在很多方面都无法满足需要. 一个原因是,许多其他的语言或者类库以声明 ...

  2. Ubuntu 修改 hosts 文件

    sudo vi /etc/hosts sudo /etc/init.d/networking restart

  3. 日志分析工具ELK(二)

    五.Logstash日志收集实践 在学习Logstash之前,我们需要先了解以下几个基本概念: logstash收集日志基本流程: input-->codec-->filter--> ...

  4. CentOS7虚拟机安装vmtools

    直接开始: 在安装vmtools之前,需要先安装两个小部件,否则将安装失败. 下面是步骤: 1.切换为root模式,需要输入root密码,但是不显示. 命令为: su 2.安装gcc 命令为: yum ...

  5. 【Linux常见命令】netstat命令

    netstat - Print network connections, routing tables, interface statistics, masquerade connections, a ...

  6. 狄慧201771010104《面向对象程序设计(java)》第十六周学习总结

    实验十六  线程技术 实验时间 2017-12-8 一.知识点总结: 1.程序与进程的概念 ‐程序是一段静态的代码,它是应用程序执行的蓝本. ‐进程是程序的一次动态执行,它对应了从代码加载.执行至执行 ...

  7. 图论--最长路--基于SPFA的调整模板

    #include<iostream> #include<queue> #include<algorithm> #include<set> #includ ...

  8. 解决ASP.NET WebPage的CS1061报错

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pg_CompanyInfo ...

  9. 学习vue第七节,filter过滤器如何的使用

    vue 过滤器如何的使用 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...

  10. java读源码 之 map源码分析(HashMap)二

    ​ 在上篇文章中,我已经向大家介绍了HashMap的一些基础结构,相信看过文章的同学们,应该对其有一个大致了了解了,这篇文章我们继续探究它的一些内部机制,包括构造函数,字段等等~ 字段分析: // 默 ...