Warning: session_start(): open(/tmp/sess_47bb6f9a7dee600e078955465e1f5194, O_RDWR) failed: No space left on device (28) in /data/wiki/inc/init.php on line 239
Warning: session_start(): Failed to read session data: files (path: ) in /data/wiki/inc/init.php on line 239
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/auth.php on line 430
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/Action/Export.php on line 103
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/Action/Export.php on line 103
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/Action/Export.php on line 103
======牛客多校第九场======
=====A=====
一道递归的签到题,用python写一行就够。
print(eval(input().replace("(", "**(")))
=====I=====
把一堆数字,重新排列拆成两个数要求乘积最小,分析后可以找到规律,按规律模拟即可。
#include
using namespace std;
#define _rep(i, a, n) for(int i = a; i < n; i++)
const int maxn = 100010;
int a[maxn], aa[maxn], res[maxn];
int main(){
int t, tmp;
cin >> t;
while(t--){
int cnt = 0;
int n;
cin >> n;
_rep(i, 0, n){
cin >> tmp;
if(tmp == 0) cnt++;
else{
a[i - cnt] = tmp;
}
}
sort(a, a + n - cnt);
int top = n - 2;
int bb = a[0];
aa[n - 1] = 0;
aa[top--] = a[1];
_rep(i, 0, cnt) aa[top--] = 0;
_rep(i, 2, n - cnt){
aa[top--] =a[i];
}
_rep(i, 0, n){
tmp = bb * aa[i] + res[i];
if(tmp > 9){
aa[i] = tmp % 10;
res[i+1] += tmp / 10;
}
else aa[i] = tmp;
}
if(aa[n - 1] > 0) printf("%d", aa[n-1]);
res[n-1] = 0;
for(int i = n - 2; i >= 0; i--) printf("%d", aa[i]), res[i] = 0;
cout << endl;
}
}