intmain() { int num; cin >> num; vector<string> resV; string a = "9"; for (int n = 0; n < num; n++) { int x; cin >> x; //long long int multi = 1; string res; while (x > 9) { x -= 9; res = a + res; //multi *= 10; } if (x != 0) { //res += multi * x; res = to_string(x) + res; } resV.push_back(res); } for (int n = 0; n < num; n++) { cout << resV[n] << endl; } return0; }
小易给定你数字A, B (A < B)和系数p, q。每次操作你可以将A变成A + p或者将p变成p * q。问至少几次操作使得B <= A。
intmain() { int num; cin >> num; vector<longlongint> resV;
for (int n = 0; n < num; n++) { longlongint a; longlongint b; longlongint p; longlongint q; cin >> a >> b >> p >> q; longlongint res = 0; if (b - a > p) { longlongint temp = b - a; longlongint multiNum = p;
while (temp > multiNum) { multiNum *= q; res++; } res++; } else { res++; } resV.push_back(res); } for (int n = 0; n < num; n++) { cout << resV[n] << endl; } return0; }
小易定义一个数字序列是完美的,当且仅当对于任意2 <= i <= n,都满足,即每个数字都要大于等于前面所有数字的和。 现在给定数字序列Ai,小易想请你从中找出最长的一段连续子序列,满足它是完美的。