Problem DescriptionFirst, the definition of a simple addition formula is given:
If there is a formula (i) + (i+1) + (i+2), (i>=0), in the process of calculation, no one digit has a carry, it is called a simple addition calculation.
For example: I=3, 3+4+5=12, there is a carry, so 3+4+5 is not a simple addition formula, as i=112, 112+113+114=339, not on any number of digits to produce a carry, so 112+113+114 is a simple addition formula.
Question: Given a positive integer n, ask when I is greater than or equal to 0 and less than N, how many equations (i) + (i+1) + (i+2) are simple addition formulas. Which n<10000.
Input FormatAn integer that represents n
output FormatAn integer that represents the number of simple addition equations
Sample Input
4
Sample output
3
Test code
1#include <stdio.h>2 3 intMain ()4 {5 intn, I, Unit, decade, Hundred, kilo, count =0;6scanf"%d", &n);7 for(i =0; I < n; i++)8 {9Unit = i%Ten;Tendecade = I/Ten%Ten; Onehundred = I/ -%Ten; Akilo = I/ +; - if(Unit <=2&& Decade <=2&& Hundred <=2&& Kilo <=2) - { thecount++; - } - } -printf"%d\n", count); + return 0; -}
3
Algorithm Training simple addition (basic type)