看了解题报告,发现看不懂 QAQ
比较简单的解释是这样的:
可以先暴力下达标,然后会发现当前数 和 上一个数 的差值是一个 固定值,
而且等于当前数与i(第i个数)的商,
于是没有规律的部分暴力解决,有规律的套公式
//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler #include <stdio.h> #include <iostream> #include <cstring> #include <cmath> #include <stack> #include <queue> #include <vector> #include <algorithm> #define ll long long #define Max(a,b) (((a) > (b)) ? (a) : (b)) #define Min(a,b) (((a) < (b)) ? (a) : (b)) #define Abs(x) (((x) > 0) ? (x) : (-(x))) using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 8000; const double eps = 1e-8; int main() { ll k, i, y, x, a, b, cnt = 1, z; while(cin >> x >> k) { if(x == 0 && k == 0) break; cout << "Case #" << cnt++ << ": "; for(i = 2; i <= k; ++i) { y = x; if(x % i != 0){ z = x / i; ++z; x = z * i; } a = x - y; b = x / i; if(a == b) break; } if(i <= k) x += (k - i) * b; cout << x << endl; } return 0; }
2014 HDU多校弟八场H题 【找规律把】,布布扣,bubuko.com
原文:http://www.cnblogs.com/wushuaiyi/p/3913462.html