# B-number

*10*

Problem Description

A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. For example, 130 and 2613 are wqb-numbers, but 143 and 2639 are not. Your task is to calculate how many wqb-numbers from 1 to n for a given integer n.

Input

Process till EOF. In each line, there is one positive integer n(1 <= n <= 1000000000).

Output

Print each answer in a single line.

Sample Input

13

100

200

1000

Sample Output

1

1

2

2

- 点赞
- 写回答
- 关注问题
- 收藏
- 复制链接分享
- 邀请回答

提交

#### 相关推荐

- 5年前回答 1 已采纳 Description For 2 non-negative integers x and y, f(x, y) is defined as the number of different bits in the binary format of x and y. For example, f(2, 3)=1,f(0, 3)=2, f(5, 10)=4. Now given 2 sets of non-negative integers A and B, for each integer b in B, you should find an integer a in A such that f(a, b) is minimized. If there are more than one such integer in set A, choose the smallest one. Input The first line of the input is an integer T (0 < T ≤ 100), indicating the number of test cases. The first line of each test case contains 2 positive integers m and n (0 < m, n ≤ 100), indicating the numbers of integers of the 2 sets A and B, respectively. Then follow (m + n) lines, each of which contains a non-negative integers no larger than 1000000. The first m lines are the integers in set A and the other n lines are the integers in set B. Output For each test case you should output n lines, each of which contains the result for each query in a single line. Sample Input 2 2 5 1 2 1 2 3 4 5 5 2 1000000 9999 1423 3421 0 13245 353 Sample Output 1 2 1 1 1 9999 0
- 4年前回答 1 已采纳 Problem Description The wide dissemination of calculators and computers is not without disadvantages. Teachers all over the world find out that even students in technical disciplines tend to have a surprising lack of calculating ability. Accustomed as they are to the use of calculators and computers, many of them are unable to make calculations like 7*8 mentally, or to factor 91 by heart. We all know, but who cares? Professor Bartjens cares. Professor Bartjens is a bit old-fashioned. He decided to give his students some training in calculating without electronic equipment - even without a slide rule. He invented a two-person game involving mental calculations. Professor Bartjens would write a positive number on the blackboard. During the game more positive numbers may appear on the blackboard. The two players will then make moves in turn. A player on move is obliged to make a move, unless the blackboard is empty, in which case the game is over. A move is one of the following: －－If you see the number 1 on the blackboard, you may take it. That means: you gain one point,and the number disappears from the blackboard. －－If you see a prime number p on the blackboard, you may subtract one. That is: you gain one point, and the p on the blackboard is replaced by p －1. －－If you see a composite number c on the blackboard, you may replace it by two smaller (positive) numbers, a and b, such that a * b = c. You do not gain any points. The goal is of course to obtain as many points as you can. Professor Bartjens was hoping that his students would find the game so interesting that they would spend all day playing, thereby improving their skills in calculation. Indeed his students did find the game interesting, and spent many hours, not so much playing the game as discussing optimal strategies. The students came to two conclusions. First, the sum of the two players' points after any given game are the same regardless of the actual scheme played. Thus," a player maximising his own points also minimises his opponent's! Second, it is always best to take a point when you have the chance. Thus, whenever prime numbers or ones are written on the blackboard, the player on move takes one of them. Here is your problem: given a starting number, and assuming both players play to maximise their own points, what will be the outcome? Input On the first line of the input is a single positive integer n, telling the number of test scenarios to follow. Each scenario consists of a single line containing the positive integer m<1000000, the number initially written on the blackboard. Output For each test scenario, output one line containing two numbers separated by one space character, equal to the points gained by the two players, both playing to maximise their own points. The first number is the number of points gained by the first player. Sample Input 6 1 2 3 4 5 6 Sample Output 1 0 1 1 2 1 2 2 3 2 2 3
- 4年前回答 1 已采纳 Friend numbers are those who are composed of the same digits, for example 3123 and 11233233 are friend numbers, but 1233432 and 123331 are not friend numbers because in the second number the 4 is missing. Your task is this: given an integer closed range [A, B], an integer number N and an integer K, you must find the Kth friend number of N in that range. Input Input will consist of several test cases each of them in a separate line. For each test case you will receive four (with no leading zeroes) integers A, B , N and K ( 0 < A<= B < 10^100 , 0 <= N <= 10^100 , 0 < K <= 10^17). Output For each test case you must print a line containing a number representing the Kth friend number in the given range, or "-1" if it is not possible to obtain the Kth friend number. Sample Input 1 191010100333 1003 20000 1 200 1 3 1 200 1 4 1 200 211 1 1 200 211 2 1 200 211 3 Sample Output 1010110131 111 -1 12 21 112
- 4年前回答 1 已采纳 Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialing the memorable TUT-GLOP. Sometimes only part of the number is used to spell a word. When you get back to your hotel tonight you can order a pizza from Gino's by dialing 310-GINO. Another way to make a telephone number memorable is to group the digits in a memorable way. You could order your pizza from Pizza Hut by calling their ``three tens'' number 3-10-10-10. The standard form of a telephone number is seven decimal digits with a hyphen between the third and fourth digits (e.g. 888-1200). The keypad of a phone supplies the mapping of letters to numbers, as follows: A, B, and C map to 2 D, E, and F map to 3 G, H, and I map to 4 J, K, and L map to 5 M, N, and O map to 6 P, R, and S map to 7 T, U, and V map to 8 W, X, and Y map to 9 There is no mapping for Q or Z. Hyphens are not dialed, and can be added and removed as necessary. The standard form of TUT-GLOP is 888-4567, the standard form of 310-GINO is 310-4466, and the standard form of 3-10-10-10 is 310-1010. Two telephone numbers are equivalent if they have the same standard form. (They dial the same number.) Your company is compiling a directory of telephone numbers from local businesses. As part of the quality control process you want to check that no two (or more) businesses in the directory have the same telephone number. This problem contains multiple test cases! The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks. The output format consists of N output blocks. There is a blank line between output blocks. Input The input will consist of one case. The first line of the input specifies the number of telephone numbers in the directory (up to 100,000) as a positive integer alone on the line. The remaining lines list the telephone numbers in the directory, with each number alone on a line. Each telephone number consists of a string composed of decimal digits, uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the characters in the string will be digits or letters. Output Generate a line of output for each telephone number that appears more than once in any form. The line should give the telephone number in standard form, followed by a space, followed by the number of times the telephone number appears in the directory. Arrange the output lines by telephone number in ascending lexicographical order. If there are no duplicates in the input print the line: No duplicates. Sample Input 1 12 4873279 ITS-EASY 888-4567 3-10-10-10 888-GLOP TUT-GLOP 967-11-11 310-GINO F101010 888-1200 -4-8-7-3-2-7-9- 487-3279 Sample Output 310-1010 2 487-3279 4 888-4567 3
- 4年前回答 1 已采纳 Description As we know, Big Number is always troublesome. But it's really important in our ACM. And today, your task is to write a program to calculate A mod B. To make the problem easier, I promise that B will be smaller than 100000. Is it too hard? No, I work it out in 10 minutes, and my program contains less than 25 lines. Input The input contains several test cases. Each test case consists of two positive integers A and B. The length of A will not exceed 1000, and B will be smaller than 100000. Process to the end of file. Output For each test case, you have to ouput the result of A mod B. Sample Input 2 3 12 7 152455856554521 3250 Sample Output 2 5 1521
- 回答 2 已采纳 Description Write a program to convert numbers in one base to numbers in a second base. There are 62 different digits: { 0-9,A-Z,a-z } HINT: If you make a sequence of base conversions using the output of one conversion as the input to the next, when you get back to the original base, you should get the original number. Input The first line of input contains a single positive integer. This is the number of lines that follow. Each of the following lines will have a (decimal) input base followed by a (decimal) output base followed by a number expressed in the input base. Both the input base and the output base will be in the range from 2 to 62. That is (in decimal) A = 10, B = 11, ..., Z = 35, a = 36, b = 37, ..., z = 61 (0-9 have their usual meanings). Output The output of the program should consist of three lines of output for each base conversion performed. The first line should be the input base in decimal followed by a space then the input number (as given expressed in the input base). The second output line should be the output base followed by a space then the input number (as expressed in the output base). The third output line is blank. Sample Input 8 62 2 abcdefghiz 10 16 1234567890123456789012345678901234567890 16 35 3A0C92075C0DBF3B8ACBC5F96CE3F0AD2 35 23 333YMHOUE8JPLT7OX6K9FYCQ8A 23 49 946B9AA02MI37E3D3MMJ4G7BL2F05 49 61 1VbDkSIMJL3JjRgAdlUfcaWj 61 5 dl9MDSWqwHjDnToKcsWE1S 5 10 42104444441001414401221302402201233340311104212022133030 Sample Output 62 abcdefghiz 2 11011100000100010111110010010110011111001001100011010010001 10 1234567890123456789012345678901234567890 16 3A0C92075C0DBF3B8ACBC5F96CE3F0AD2 16 3A0C92075C0DBF3B8ACBC5F96CE3F0AD2 35 333YMHOUE8JPLT7OX6K9FYCQ8A 35 333YMHOUE8JPLT7OX6K9FYCQ8A 23 946B9AA02MI37E3D3MMJ4G7BL2F05 23 946B9AA02MI37E3D3MMJ4G7BL2F05 49 1VbDkSIMJL3JjRgAdlUfcaWj 49 1VbDkSIMJL3JjRgAdlUfcaWj 61 dl9MDSWqwHjDnToKcsWE1S 61 dl9MDSWqwHjDnToKcsWE1S 5 42104444441001414401221302402201233340311104212022133030 5 42104444441001414401221302402201233340311104212022133030 10 1234567890123456789012345678901234567890
- 回答 1 已采纳 Description The city of Hakodate recently established a commodity exchange market. To participate in the market, each dealer transmits through the Internet an order consisting of his or her name, the type of the order (buy or sell), the name of the commodity, and the quoted price. In this market a deal can be made only if the price of a sell order is lower than or equal to the price of a buy price. The price of the deal is the mean of the prices of the buy and sell orders, where the mean price is rounded downward to the nearest integer. To exclude dishonest deals, no deal is made between a pair of sell and buy orders from the same dealer. The system of the market maintains the list of orders for which a deal has not been made and processes a new order in the following manner. For a new sell order, a deal is made with the buy order with the highest price in the list satisfying the conditions. If there is more than one buy order with the same price, the deal is made with the earliest of them. For a new buy order, a deal is made with the sell order with the lowest price in the list satisfying the conditions. If there is more than one sell order with the same price, the deal is made with the earliest of them. The market opens at 7:00 and closes at 22:00 everyday. When the market closes, all the remaining orders are cancelled. To keep complete record of the market, the system of the market saves all the orders it received everyday. The manager of the market asked the system administrator to make a program which reports the activity of the market. The report must contain two kinds of information. For each commodity the report must contain information on the lowest, the average and the highest prices of successful deals. For each dealer, the report must contain information on the amounts the dealer paid and received for commodities. Input The input contains several data sets. Each data set represents the record of the market on one day. The first line of each data set contains an integer n (n < 1000) which is the number of orders in the record. Each line of the record describes an order, consisting of the name of the dealer, the type of the order, the name of the commodity and the quoted price. They are separated by a single space character. The name of a dealer consists of capital alphabetical letters and is less than 10 characters in length. The type of an order is indicated by a string, "BUY" or "SELL". The name of a commodity is a single capital letter. The quoted price is a positive integer less than 1000. The orders in a record are arranged according to time when they were received and the first line of the record corresponds to the oldest order. The end of the input is indicated by a line containing a zero. Output The output for each data set consists of two parts separated by a line containing two hyphen ('-') characters. The first part is output for commodities. For each commodity, your program should output the name of the commodity and the lowest, the average and the highest prices of the successful deals in on line. The name and the prices in a line should be separated by a space character. The average price is rounded downward to the nearest integer. The output should contain only the commodities for which deals are made and the order of the output must be alphabetic. The second part is output for dealers. For each dealer, your program should output the name of the dealer, the amounts the dealer paid and received for commodities. The name and the numbers in a line should be separated by a space character. The output should contain all the dealers who transmitted orders. The order of dealers in the output must be lexicographic on their names. The lexicographic order is the order in which words in dictionaries are arranged. The output for each data set should be followed by a line containing ten hyphen ('-') characters. Sample Input 3 PERLIS SELL A 300 WILKES BUY A 200 HAMMING SELL A 100 4 BACKUS SELL A 10 FLOYD BUY A 20 IVERSON SELL B 30 BACKUS BUY B 40 7 WILKINSON SELL A 500 MCCARTHY BUY C 300 WILKINSON SELL C 200 DIJKSTRA SELL B 100 BACHMAN BUY A 400 DIJKSTRA BUY A 600 WILKINSON SELL A 300 2 ABCD SELL X 10 ABC BUY X 15 2 A SELL M 100 A BUY M 100 0 Sample Output A 150 150 150 -- HAMMING 0 150 PERLIS 0 0 WILKES 150 0 ---------- A 15 15 15 B 35 35 35 -- BACKUS 35 15 FLOYD 15 0 IVERSON 0 35 ---------- A 350 450 550 C 250 250 250 -- BACHMAN 350 0 DIJKSTRA 550 0 MACCARTHY 250 0 WILKINSON 0 1150 ---------- X 12 12 12 -- ABC 12 0 ABCD 0 12 ---------- -- A 0 0 ----------
- 4年前回答 1 已采纳 Once I was asked to play a game with a stranger,the rule of the game was as follows. I and the stranger had different rules. First there was a number n0(1 < n0 < 108),i was asked to choose a number a which is larger or equal to n0 but less or equal to n02,and then the stranger chose a number b according to the number I chose, a/b (a mod b=0) should equal to qk,in which q is a prime number and k is positive, and b should not equal to a. Then I chose number based on the stranger's number(regard the b as n1) on my own rule again, we chose numbers in turns in different rules. When I chose 1990, then I won the game, when the stranger chose number 1, then he won the game. For example, when n0 = 2, then I could choose 2,3,4 as a, then the stranger can always chose 1 at his first round(because 2,3 are prime numbers and 4 = 22), so the stranger won the game. Not long, I found the result of the game is in line with the initial number n0, so I want to know before I play this game, will I won this game with the number n0, or is there sometimes nobody will win the game, can you tell me? Input There no more than 10000 cases, proceed to the end of file. In each line there is a single number n0(1 < n0 < 108). Output For each case, if I will win, then output "I will win!!"(without the quotes),if the stranger will win, then output "The stranger will win!!"(without the quotes),if nobody can win the game, output "It's an endless game!!"(without the quotes). Sample Input 2 7 345 Sample Output The stranger will win!! It's an endless game!! I will win!!
- 4年前ezoixx130的博客 B-number Description 一个wqb号或简称B号是一个非负整数，其十进制形式包含子串“13”，可以除以13.例如，130和2613是wqb数，而143和 2639不是。 您的任务是为给定的整数n计算从1到n的wqb数。 （原文：A wqb-...
- 随心丶而遇的博客 B-number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3376 Accepted Submission(s): 1891 Problem Description A wqb-number, or B-number f
- shiyicode的博客 题目链接：[kuangbin带你飞]专题十五 数位DP G - B-number题意 求1～n的范围里含有13且能被13整除的数字的个数。 思路 首先，了解这样一个式子：a％m == ((b%m)*c+d)%m; 式子的正确是显然的，就不证明了。 ...
- 10年前magicnumber的博客 Problem Description A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can
- ACM_Ted的博客 B-number 题目：http://acm.hdu.edu.cn/showproblem.php?pid=3652 题意：问1~n中包含"13"序列且能被13整除的数有多少个。 题解：详情见代码注释。 代码： #include #include using namespace std; int dp[15]...
- 键盘上的舞者的博客 Problem Description ...A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. For example, 130 and 2613 are wqb-numbers
- JAVA/C++的博客 一:杭电原题摘录 ...sectionid=2&problemid=8 二.题目分析 很容易就能想到递归,但是超出内存 int fac(int a,int b,int n)//超出内存 { int f; if (n== 1||n==2) f...
- hesorchen的博客 问一个区间内的B-number的数量，B-number的定义是：数位中含有13，另外能被13整数。例如13，130就是B-number。 数位中含有13是数位DP板子，取模使用秦九韶算法。 AC代码： #include <bits/stdc++.h> using ...
- xyqzki的博客 https://leetcode.com/problems/super-ugly-number/ https://leetcode.com/problems/ugly-number-ii/ 参考 http://bookshadow.com/weblog/2015/12/03/leetcode-super-ugly-number/
- faithdmc的博客 Problem Description There is a special number sequence which has n+1 integers. For each number in sequence, we have two rules: ● ai ∈ [0,n] ...For sequence a and sequence b,
- 4年前回答 1 已采纳 Problem Description Number Link is a famous game available in platforms including iOS and Android. Given a board with n rows and m columns, the target of the game is to connect pairs of grids with the same numbers. Once two numbers are paired, the path connecting them will occupy the corresponding grids. The path can only go vertically or horizontally. Note that, no two paths could intersect (by sharing the same grid) in any grid. In this problem, you are going to play a modified version, called Number Link ++. See the picture below for an example. In this new game, you can use two types of paths. Type I is to connect two number grids with different parities (i.e., connect odd number with any other even number). It might be hard to cover the entire grid with only type I path, so we allow type II path, which is a circle path covers only the empty grids (the only special case of type II path is a path only connecting two adjacent empty grids; see the figure above). Since there is no free lunch, we have no free path either. When goes from grid (a,b) to an adjacent grid (c,d), you have to pay for a certain amount of tolls. The cost is the same when goes back from (c,d) to (a,b). Usually the cost of a path is the sum of tolls you paid by traveling along the grids on this path. The only exception is for the special case of type II path. In that case, you have to pay twice the cost (since it is a circle). The total cost of the game is the sum of costs for all the paths. Can you help me figure out the paths so that each grid is on exactly one path? If there exists such solution, what is the minimum possible cost? Input The first line of input consists of an integer T, which is the number of test cases. Each case begins with two integers, n and m, in a line (1≤n,m≤50). The next n lines describe the board. Each line consists of m nonnegative numbers, which describe the status of each column from left to right. If the number is zero, then the grid is empty; otherwise it indicates the number on the corresponding grid. The next n−1 lines each have m nonnegative numbers, which describe the cost of vertical connection. The j-th number in i-th line is the cost when travels from grid (i,j) to (i+1,j). The next n lines each have m−1 nonnegative numbers, which describe the cost of horizontal connection. The j-th number in i-th line is the cost for a path to go from grid (i,j) to (i,j+1). All the numbers, including the answer, can be represented using 32-bit signed integer. Output For each test case, first output the case number, then output a single number, which is the minimum cost possible to finish the game. When there is no solution available, simply output -1. Sample Input 3 3 3 1 0 0 1 0 0 2 0 2 1 2 1 2 1 1 3 1 5 6 1 4 1 4 1 1 2 2 1 2 3 3 5 0 0 0 0 0 0 5 0 6 0 0 0 0 0 0 1 1000 1000 1000 1 1 1000 1000 1000 1 1 1 1 1 1000 1 1 1000 1 1 1 1 Sample Output Case #1: 10 Case #2: -1 Case #3: 14
- 3月前水蛙菌的博客 Now Alice want to build an array B by a parameter K as following rules: Initially, the array B is empty. Consider each interval in array A. If the length of this interval is less than K, then ignore ...