Codeforces Round #278 (Div. 2)-A. Giga Tower_html/css_WEB-ITnose
Giga Tower
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Giga Tower is the tallest and deepest building in Cyberland. There are 17?777?777?777 floors, numbered from ?-?8?888?888?888 to 8?888?888?888. In particular, there is floor 0 between floor ?-?1 and floor 1. Every day, thousands of tourists come to this place to enjoy the wonderful view.
In Cyberland, it is believed that the number "8" is a lucky number (that's why Giga Tower has 8?888?888?888 floors above the ground), and, an integer is lucky, if and only if its decimal notation contains at least one digit "8". For example, 8,??-?180,?808 are all lucky while42,??-?10 are not. In the Giga Tower, if you write code at a floor with lucky floor number, good luck will always be with you (Well, this round is #278, also lucky, huh?).
Tourist Henry goes to the tower to seek good luck. Now he is at the floor numbered a. He wants to find the minimum positive integer b, such that, if he walks b floors higher, he will arrive at a floor with a lucky number.
Input
The only line of input contains an integer a (?-?109?≤?a?≤?109).
Output
Print the minimum b in a line.
Sample test(s)
input
179
output
input
-1
output
input
18
output
10
Note
For the first sample, he has to arrive at the floor numbered 180.
For the second sample, he will arrive at 8.
Note that b should be positive, so the answer for the third sample is 10, not 0.
题目大意:给一个数n,加上k之后,使得n中包含数字8. 求这样的最小的正整数k.
解题思路:其实本题的最大的k也就是16(n == -8时),直接在这里面暴力查找,然后每个都判断是否含有8即可。不过要注意,在判断的时候,如果是直接取模的话,则要注意 -8 % 10 == -8.
AC代码:
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;#define INF 0x7ffffffflong long a;int check(long long x){ int flag = 0; while(x){ int f = x%10; if(abs(f) == 8){ //注意是abs(f) flag = 1; break; } x /= 10; } return flag;}int main(){ #ifdef sxk freopen("in.txt","r",stdin); #endif long long n; while(scanf("%lld",&n)!=EOF) { for(long long i=1; i<=16 && n+i <= 8888888888 && n-i>=-8888888888 ; i++){ if(check(n+i)){ printf("%lld\n", i); break; } } } return 0;}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex
