Problem - D - Codeforces 题意:问能否在进行K次操作的情况下,将两个数变得相同,操作为每次选择一因子,然后除该因子. 题解:要判断该数最多能进行几次除的操作,其实就是判断这个数有多少个质因子,然后判断最后最多进行的操作数和要求的操作数大小关系,其中K=1的时候要特判一下. 其中开始的时候一直TLE,后来发现是long long 的问题,在没必要的情况下, long long的运行速度是慢与int的,这会在数据多的时候TLE. 详情可见  performance - C++…
problem 728. Self Dividing Numbers solution1: 使用string类型来表示每位上的数字: class Solution { public: vector<int> selfDividingNumbers(int left, int right) { vector<int> res; for (int i=left; i<=right; ++i) { bool flag = isSDN(i); if(flag) res.push_ba…
目录 1 问题描述 2 解决方案   1 问题描述 Problem Description We call a number interesting, if and only if: 1. Its digits consists of only 0, 1, 2 and 3, and all these digits occurred at least once. 2. Inside this number, all 0s occur before any 1s, and all 2s occur…
A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. Also, a self-dividing number is not allowed to contain the digit zero. G…
题意 : 将从 1 ~ n 的数分成两组,要求两组和的差值尽可能小,并输出其中一组的具体选数情况 分析 : 如果将这 n 个数从大到小四个一组来进行选择的话那么差值就为 0 ,然后再来考虑 n%4 != 0 的情况.举个例子就是 n = 9 的时候,我们考虑 6 7 8 9 ,将6.9放入一组,7.8放入第二组,那么此时差值就会为 0 ,接下来再对 2 3 4 5 进行同样的取法此时差值仍为 0 ,最后剩下一个 1 ,很显然最后的最小差值应当为 1 .其实综合考虑一下 n%4 != 0 的情况只…
D. Magic Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of…
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, 349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337 That is, 349 took three iterations to arrive at a palindrome. Al…
1 问题描述 Problem Description We call a number interesting, if and only if: 1. Its digits consists of only 0, 1, 2 and 3, and all these digits occurred at least once. 2. Inside this number, all 0s occur before any 1s, and all 2s occur before any 3s. The…
http://codeforces.com/contest/340/problem/C #include <cstdio> #include <cstring> #include <algorithm> #define maxn 100010 #define ll __int64 using namespace std; ll a[maxn]; int n; ll gcd(ll a,ll b) { ?a:gcd(b,a%b); } int main() { scanf(…
CF291E 题意:一棵树,每条边上有一些字符,求目标串出现了多少次 直接求目标串的fail然后一边dfs一边跑kmp 然后就被特殊数据卡到\(O(n^2)\)了... 因为这样kmp复杂度分析的基础就没有了,now指针可能每个孩子都减少n次 所以怒加trie图优化 貌似有人写了倍增+哈希的做法........ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm&…