标签:2015百度之星初赛2 数学
#include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<iostream> #include<algorithm> #include<vector> #include<map> #include<queue> #include<stack> #include<string> #include<map> #include<set> #define eps 1e-6 using namespace std; #define LL long long //const int maxn = ; const int INF = 0x3f3f3f3f; //freopen("input.txt", "r", stdin); const LL po[] = { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000}; int main() { int T, kase = 0; scanf("%d", &T); while(T--) { double x; cin >> x; LL nx = x * 1000000 + 0.5; LL changshu = 1000000; //将浮点数转换为整形 vector<LL> ans; LL power, firnum, lasnum; for(power = 0; power < 9; power++) { for(firnum = 1; firnum < 10; firnum++) { for(lasnum = 0; lasnum < 10; lasnum++) { if((lasnum*(po[power]*changshu-nx)+firnum*(changshu-po[power]*nx)) % (nx-changshu) != 0) continue; LL mid = (lasnum*(po[power]*changshu-nx) + firnum*(changshu-po[power]*nx) )/ (nx-changshu); if(mid % 10 != 0) continue; if(mid >= po[power] || mid < 0) continue; ans.push_back(firnum*po[power] + mid + lasnum); } } } cout << nx << endl; printf("Case #%d:\n", ++kase); int sz = ans.size(); if(!sz) puts("0"); else { cout << sz << endl; cout << ans[0]; for(int i = 1; i < sz; i++) cout << " " << ans[i]; cout << endl; } } return 0; }
标签:2015百度之星初赛2 数学
原文地址:http://blog.csdn.net/u014664226/article/details/46392015