1.题目描述 X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Each digit must be rotated - we cannot choose to leave it alone. A number is valid if each digit remains a digit afte…
直接硬搜就可以了,只是需要考虑k为0的情况. public class Solution { /* * @param : An integer * @param : An integer * @return: An integer denote the count of digit k in 1..n */ public int digitCounts(int k, int n) { int ans = (k==0 ? 1 : 0); for(int i=0; i<=n; i++){ ans +…
Link #include<bits/stdc++.h> using namespace std; #define int long long const int MAXN=1e6; int T,n,m,f[MAXN+10],g[MAXN+10],inv[MAXN+10]; const int mod=1e9+7; inline int add(int x,int y){return (x+y+mod)%mod;} inline int mul(int x,int y){return 1ll*…
一.Description The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are sum…
传送门 Description Using at most 7 matchsticks, you can draw any of the 10 digits as in the following picture: The picture shows how many sticks you need to draw each of the digits. Zaytoonah has a number that consists of N digits. She wants to move som…
E. Vladik and cards 题目链接 http://codeforces.com/contest/743/problem/E 题面 Vladik was bored on his way home and decided to play the following game. He took n cards and put them in a row in front of himself. Every card has a positive integer number not e…
题目: Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. For example, 123 -> "One Hundred Twenty Three" 12345 -> "Twelve Thousand Three Hundred Forty Five" 1234567…
CA Loves GCD 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/B Description CA is a fine comrade who loves the party and people; inevitably she loves GCD (greatest common divisor) too. Now, there are different numbers. Each time, CA will se…
10399: F.Turing equation Time Limit: 1 Sec Memory Limit: 128 MB Submit: 151 Solved: 84 [Submit][Status][Web Board] Description The fight goes on, whether to store numbers starting with their most significant digit or their least significant digit…
Problem UVA116-Unidirectional TSP Accept: 7167 Submit: 56893Time Limit: 3000 mSec Problem Description Input The input consists of a sequence of matrix specifications. Each matrix specification consists of the row and column dimensions in that order…
原题链接在这里:https://leetcode.com/problems/path-sum-iv/description/ 题目: If the depth of a tree is smaller than 5, then this tree can be represented by a list of three-digits integers. For each integer in this list: The hundreds digit represents the depth …
[算法]数学 [题意]a数组初始为0,t=1~n,每次01翻转t的倍数,最终为0的数字定义为好数,求好数个数 [题解]一个数字为好数的条件是翻转偶数次,也即一个数是好数当且仅当有偶数个因子时. 因子都是两两配对的,只有完全平方数才拥有奇数个因子. 对于n以内的数字,1~√n的平方就是所有完全平方数. ans=n-√n. #include<cstdio> #include<math.h> int main(){ long long n; scanf("%lld",…
原题链接在这里:https://leetcode.com/problems/output-contest-matches/description/ 题目: During the NBA playoffs, we always arrange the rather strong team to play with the rather weak team, like make the rank 1 team play with the rank nth team, which is a good…
[UOJ#278][UTR #2]题目排列顺序 试题描述 “又要出题了.” 宇宙出题中心主任 —— 吉米多出题斯基,坐在办公桌前策划即将到来的 UOI. 这场比赛有 n 道题,吉米多出题斯基需要决定这些题目的难度,然后再在汪洋大海中寻找符合该难度的题目. 题目的难度可以用一个 1 到 n 的排列 a1,…,an 表示,其中 ai 表示第 i 道题目在这 n 道题目中是第 ai 简单的题目,即恰有 ai−1 道题目比第 i 道题目简单. 经验丰富的吉米多出题斯基早就悟出了一种科学地决定难度顺序的方…