您的位置:首页 > 其它

[csu1392]YY一下

2015-04-12 06:45 429 查看
题意:给定x,求有多少个10^8以内的数满足这个数乘以x以后,最高位到了最低位。设最高位的数字和剩余长度,列等式推理即可。

#pragma comment(linker, "/STACK:10240000,10240000")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <ctime>
#include <cctype>
#include <set>

using namespace std;

#define mem0(a) memset(a, 0, sizeof(a))
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define define_m int m = (l + r) >> 1
#define Rep(a, b) for(int a = 0; a < b; a++)
#define lowbit(x) ((x) & (-(x)))
#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) {}
#define constructInt3(name, a, b, c) name(int a = 0, int b = 0, int c = 0): a(a), b(b), c(c) {}
#define constructInt2(name, a, b) name(int a = 0, int b = 0): a(a), b(b) {}

typedef double db;
typedef long long LL;
typedef pair<int, int> pii;
typedef multiset<int> msi;
typedef multiset<int>::iterator msii;
typedef set<int> si;
typedef set<int>::iterator sii;
typedef vector<int> vi;

const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[8] = {0, -1, 0, 1, -1, 1, 1, -1};
const int maxn = 1e5 + 7;
const int maxm = 1e5 + 7;
const int maxv = 1e7 + 7;
const int MD = 1e9 +7;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-10;

int digit(LL x) {
int cnt = 0;
while (x) {
cnt++;
x /= 10;
}
return cnt;
}

int main() {
//freopen("in.txt", "r", stdin);
double tx;
while (cin >> tx) {
LL x = (int)(tx * 10000 + 0.5), get = 0;
if (x >= 100000) {
puts("No solution");
continue;
}
LL p = 1;
for (int i = 0; i <= 7; i++) {
for (int k = 1; k <= 9; k++) {
LL tmp = k * (x * p - 1e4);
if (tmp % (LL)(1e5 - x)) continue;
tmp /= 1e5 - x;
if (digit(tmp) == i) {
printf("%d", k);
if (tmp > 0) printf("%d", tmp);
puts("");
get = 1;
}
}
p *= 10;
}
if (!get) puts("No solution");
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: