Start: Jun, 30, 2019 09:00:00
2019年度暑期短学期第十天 助教场
End: Jul, 08, 2019 23:59:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 4ms
Memory: 1756kB
Author: 2017212212148
In contest: 1290

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<set>
#include<string>
#include<map>
#include<vector>
#include<ctime>
#include<stack>
#include<fstream>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=1e5+60;
const int INF=0x3f3f3f3f;
const double PI = acos(-1.0);
int ma[100];
int main(){
    ma['+']=1;
    ma['-']=2;
    ma['*']=5;
    ma['/']=4;
    ma['%']=3;
    int n;
    scanf("%d",&n);
    while(n--){
        int a,b,c;
        char x,y;
        scanf("%d %c %d %c %d",&a,&x,&b,&y,&c);
        int ans=0;
        if(ma[x]>=3&&ma[y]>=3){
            if(ma[x]==4){
                ans+=a/b;
            }
            else if(ma[x]==5)
                ans+=a*b;
            else
                ans+=a%b;
            if(ma[y]==4){
                ans/=c;
            }
            else if(ma[y]==5)
                ans*=c;
            else
                ans%=c;
        }
        else if(ma[x]>=3||ma[y]>=3){
            if(ma[x]>=3){
                if(ma[x]==4){
                    ans+=a/b;
                }
                else if(ma[x]==5)
                    ans+=a*b;
                else
                    ans+=a%b;
                if(ma[y]==2){
                    ans-=c;
                }
                else
                    ans+=c;
            }
            else{
                if(ma[y]==4){
                    ans+=b/c;
                }
                else if(ma[y]==5)
                    ans+=b*c;
                else
                    ans+=b%c;
                if(ma[x]==2){
                    ans=a-ans;
                }
                else
                    ans=a+ans;
            }
        }
        else{
            if(ma[x]==1){
                ans+=a+b;
            }
            else if(ma[x]==2){
                ans+=a-b;
            }
            else
                ans+=a%b;
            if(ma[y]==1){
                ans+=c;
            }
            else if(ma[y]==2){
                ans-=c;
            }
            else
                ans%=c;
        }
        printf("%d\n",ans);
    }
}
/*char a[maxn];
struct node{
    int l,r;
    bool operator < (const node &other) const {
        if (l == other.l) return r < other.r;
        else return l < other.l;
    }
}coor[maxn];
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        int n;
        scanf("%d",&n);
        int mini=1e9+10;
        int maxx=0;
        for(int i=1;i<=n;i++){
            scanf("%d %d",&coor[i].l,&coor[i].r);
            mini=min(mini,coor[i].l);
            maxx=max(maxx,coor[i].r);
        }
        sort(coor+1,coor+n+1);
        int ans=0,temp=0;
        priority_queue<int,vector<int>,greater<int> >q;
        for(int i=mini;i<=maxx;i++){
            while(temp<=n&&coor[temp].l<=i)
                q.push(coor[temp++].r);
            while(!q.empty()&&q.top()<i)
                q.pop();
            while(!q.empty()){
                q.pop();
                ans++;
            }
            if(q.empty()){
                if(temp>n)
                    break;
                i=max(i,coor[temp].l-1);
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}*/