题意:给定x,求有多少个10^8以内的数满足这个数乘以x以后,最高位到了最低位。设最高位的数字和剩余长度,列等式推理即可。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #pragma comment(linker, "/STACK:10240000,10240000") 2 3 #include <iostream> 4 #include <cstdio> 5 #include <algorithm> 6 #include <cstdlib> 7 #include <cstring> 8 #include <map> 9 #include <queue> 10 #include <deque> 11 #include <cmath> 12 #include <vector> 13 #include <ctime> 14 #include <cctype> 15 #include <set> 16 17 using namespace std; 18 19 #define mem0(a) memset(a, 0, sizeof(a)) 20 #define lson l, m, rt << 1 21 #define rson m + 1, r, rt << 1 | 1 22 #define define_m int m = (l + r) >> 1 23 #define Rep(a, b) for(int a = 0; a < b; a++) 24 #define lowbit(x) ((x) & (-(x))) 25 #define constructInt4(name, a, b, c, d) name(int a = 0, int b = 0, int c = 0, int d = 0): a(a), b(b), c(c), d(d) {} 26 #define constructInt3(name, a, b, c) name(int a = 0, int b = 0, int c = 0): a(a), b(b), c(c) {} 27 #define constructInt2(name, a, b) name(int a = 0, int b = 0): a(a), b(b) {} 28 29 typedef double db; 30 typedef long long LL; 31 typedef pair<int, int> pii; 32 typedef multiset<int> msi; 33 typedef multiset<int>::iterator msii; 34 typedef set<int> si; 35 typedef set<int>::iterator sii; 36 typedef vector<int> vi; 37 38 const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; 39 const int dy[8] = {0, -1, 0, 1, -1, 1, 1, -1}; 40 const int maxn = 1e5 + 7; 41 const int maxm = 1e5 + 7; 42 const int maxv = 1e7 + 7; 43 const int MD = 1e9 +7; 44 const int INF = 1e9 + 7; 45 const double PI = acos(-1.0); 46 const double eps = 1e-10; 47 48 int digit(LL x) { 49 int cnt = 0; 50 while (x) { 51 cnt++; 52 x /= 10; 53 } 54 return cnt; 55 } 56 57 int main() { 58 //freopen("in.txt", "r", stdin); 59 double tx; 60 while (cin >> tx) { 61 LL x = (int)(tx * 10000 + 0.5), get = 0; 62 if (x >= 100000) { 63 puts("No solution"); 64 continue; 65 } 66 LL p = 1; 67 for (int i = 0; i <= 7; i++) { 68 for (int k = 1; k <= 9; k++) { 69 LL tmp = k * (x * p - 1e4); 70 if (tmp % (LL)(1e5 - x)) continue; 71 tmp /= 1e5 - x; 72 if (digit(tmp) == i) { 73 printf("%d", k); 74 if (tmp > 0) printf("%d", tmp); 75 puts(""); 76 get = 1; 77 } 78 } 79 p *= 10; 80 } 81 if (!get) puts("No solution"); 82 } 83 return 0; 84 }