/ WOJ /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 成绩取消 0ms 0 Bytes

代码

#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using ll = long long;
using db = double;
using ull = unsigned long long;
#define endl "\n"
#define vec vector
#define int128 __int128
#define gcd __gcd
#define str string
#define unmap unordered_map
#define db double
#define unset unordered_set
ostream &operator<<(ostream &os , int128 num){
    if (num == 0) return os << "0";
    str s;
    while(num > 0){
        s.push_back('0' + num % 10);
        num /= 10;
    }
    reverse(s.begin() , s.end());
    return os << s;
}
ll read(){
    int f = 1; ll res = 0;
    char ch = getchar();
    while(!isdigit(ch)){
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while(isdigit(ch)){
        res = (res << 3) + (res << 1) + (ch - '0');
        ch = getchar();
    }
    return res * f;
}
//#define int long long
const int N = 105;
int a[N] , b[N] , c[N];
char s[N * N];
void solve() {
    while (scanf("%s" , s) != EOF) {
        int n = 0 , m = 0;
        bool f = 0 ; int len = strlen(s);
        for (int i = 0 ; i < len ; ) {
            int x = 0 , y = 0;
            while (i < len && s[i] < '0' || s[i] > '9') {
                if (s[i] == ')') f = 1;
                i ++;
            }
            if (i >= len) break;
            while (s[i] >= '0' && s[i] <= '9') {
                x = x * 10 + s[i] - '0';
                i ++;
            }
            if (s[i] != 'a') {
                if (!f) a[y] = x;
                else b[y] = x;
                continue;
            }
            i += 2;
            while (s[i] >= '0' && s[i] <= '9') {
                y = y * 10 + s[i] - '0';
                i ++;
            }
            if (f) b[y] = x , m = max(m , y);
            else a[y] = x , n = max(n , y);
        }
        memset(c , 0 , sizeof c);
        for (int i = 0 ; i <= n ; i++)
            for (int j = 0 ; j <= m ; j++)
                c[i + j] += a[i] * b[j];
        for (int i = n + m ; i >= 0 ; i--) {
            if (i != n + m) putchar('+');
            printf("%d" , c[i]);
            if (i) printf("a^%d" , i);
        }
        printf("\n");
    }
}
signed main() {
    IOS
    int t = 1; //cin >> t;
    while (t --) solve();
    return 0;
}

信息

递交者
类型
递交
题目
P1000 云剪贴板
题目数据
下载
语言
C++
递交时间
2025-07-14 20:35:49
评测时间
2025-07-14 20:37:22
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes