• 个人简介

    【CSDN博客】

    -std=c++11

    bits/stdc++.h

    #include <bits/stdc++.h>
    using namespace std;
    string n, n1, n2, n4, n5;
    long double c2 = 0, e = 0, d = 0, j2 = 0, a = 0, b1 = 0, b2 = 0, cnt = 0, c = 0, j3 = 0;
    bool abc = false, zxc = true, asd = false, bnm = true, aaj = false, akb = false;;
    long double lgn(long double dsd, long long saf){
    	long double lha = 1;
    	for (long long i = 0;i < saf;i++){
    		lha *= dsd;
    	}
    	return lha;
    }
    void qsc(bool wdv){
    	if (wdv){
    		for (long long i = 0;i < c2;i++){
    			b1 /= 10.0;
    		}
    	}else{
    		for (long long i = 0;i < c2;i++){
    			b2 /= 10.0;
    		}
    	}
    	c2 = 0;
    }
    void qwe() {
    	for (long long i2 = 0;i2 < j3;i2++){
    		if (n[i2] == '(' && (i2+1) >= j3){
    			aaj = true;
    		}
    		n1 += n[i2];
    	}
    	for (long long i3 = j2+1;i3 < n.size();i3++){
    		if (n[i3] == ')' && (i3-1) < j2+1){
    			akb = true;
    		}
    		n2 += n[i3];
    	}
    	if (aaj && akb){
    		for (long long i4 = 0;i4 < n1.size()-1;i4++){
    			n4 += n1[i4];
    		}
    		for (long long i5 = 1;i5 < n2.size();i5++){
    			n5 += n2[i5];
    		}
    		n1 = n4;
    		n2 = n5;
    	}
    	n = n1 + to_string(cnt) + n2;
    	n1 = "";
    	n2 = "";
    	n4 = "";
    	n5 = "";
    	aaj = false;
    	akb = false;
    	cnt = 0;
    }
    void rty (char wsx, char edc, long long dfg, long long vbn){
    	for (long long i = dfg;i < vbn;i++){
    		if (n[i] == wsx || n[i] == edc){
    			for (long long j = i-1;j >= 0;j--){
    				if (not (n[j] >= '0' && n[j] <= '9') && not (n[j] == '.') || j == 0){
    					for (long long k = i-1;k >= j;k--){
    						if (n[k] == '.'){
    							c2 += c;
    							zxc = false;
    						}
    						if (n[k] >= '0' && n[k] <= '9'){
    							j3 = k;
    							if (n[k] != '0'){
    								asd = true;
    							}
    							if (zxc){
    								if (asd){
    									e++;
    								}
    							}
    							a = int(n[k]) - 48;
    							for (long long q = 0;q < c;q++){
    								a *= 10;
    							}
    							c++;
    							b1 += a;
    						}
    					}
    					abc = true;
    				}
    				if (abc){
    					if (zxc){
    						e = 0;
    					}
    					if (c2 != 0){
    						qsc(true);
    					}
    					d += e;
    					asd = false;
    					abc = false;
    					zxc = true;
    					c = 0;
    					e = 0;
    					break;
    				}
    			}
    			for (long long j = i+1;j < n.size();j++){
    				if (not (n[j] >= '0' && n[j] <= '9') && not (n[j] == '.') || j == n.size()-1){
    					for (long long k = j;k > i;k--){
    						if (n[k] == '.'){
    							c2 += c;
    							zxc = false;
    						}
    						if (n[k] >= '0' && n[k] <= '9'){
    							if (k > j2){
    								j2 = k;
    							}
    							if (n[k] != '0'){
    								asd = true;
    							}
    							if (zxc){
    								if (asd){
    									e++;
    								}
    							}
    							a = int(n[k]) - 48;
    							for (long long q = 0;q < c;q++){
    								a *= 10;
    							}
    							c++;
    							b2 += a;
    						}
    					}
    					abc = true;
    				}
    				if (abc){
    					if (zxc){
    						e = 0;
    					}
    					if (c2 != 0){
    						qsc(false);
    					}
    					d += e;
    					abc = false;
    					asd = false;
    					zxc = true;
    					c = 0;
    					e = 0;
    					break;
    				}
    			}
    			if (n[i] == '*'){
    				cnt = b1 * b2;
    				qwe();
    				j3 = 0;
    				j2 = 0;
    				d = 0;
    				b1 = 0;
    				b2 = 0;
    				bnm = false;
    				break;
    			}else if (n[i] == '/'){
    				cnt = (b1 * 1.0) / (b2 * 1.0);
    				qwe();
    				j3 = 0;
    				j2 = 0;
    				d = 0;
    				b1 = 0;
    				b2 = 0;
    				bnm = false;
    				break;
    			}else if (n[i] == '+'){
    				cnt = b1 + b2;
    				qwe();
    				j3 = 0;
    				j2 = 0;
    				d = 0;
    				b1 = 0;
    				b2 = 0;
    				bnm = false;
    				break;
    			}else if (n[i] == '-'){
    				cnt = b1 - b2;
    				qwe();
    				j3 = 0;
    				j2 = 0;
    				d = 0;
    				b1 = 0;
    				b2 = 0;
    				bnm = false;
    				break;
    			}else if (n[i] == '^'){
    				cnt = lgn(b1, b2);
    				qwe();
    				j3 = 0;
    				j2 = 0;
    				d = 0;
    				b1 = 0;
    				b2 = 0;
    				bnm = false;
    				break;
    			}
    		}
    	}
    }
    long long len[100];
    int main () {
    	cin >> n;
    	long long dfs = 0, dfs2 = 0, rfv = 0, tgb = 0, ik = 0, jkl = 0, rfv2 = 0, tgb2 = 0, cnt2 = 0;
    	bool qpz = false;
    	for (long long yhn = 0;yhn < n.size();yhn++){
    		if (n[yhn] == '*' || n[yhn] == '/'){
    			if (qpz){
    				rfv2++;
    			}else{
    				rfv++;
    			}
    		}else if (n[yhn] == '+' || n[yhn] == '-'){
    			if (qpz){
    				tgb2++;
    			}else{
    				tgb++;
    			}
    		}else if (n[yhn] == '^'){
    			if (qpz){
    				dfs2++;
    			}else{
    				dfs++;
    			}
    		}else if (n[yhn] == '('){
    			ik++;
    			qpz = true;
    			len[jkl++] = yhn;
    		}else if (n[yhn] == ')'){
    			len[jkl++] = yhn;
    			qpz = false;
    		}
    	}
    	for (long long ol = 0;ol < ik;ol++){
    		for (long long sgf1 = 0;sgf1 < dfs2;sgf1++){
    			rty('^', '^',len[ol+ol]+1 , len[ol+ol+1]);
    		}
    		for (long long qaz1 = 0;qaz1 < rfv2;qaz1++){
    			rty('*', '/', len[ol+ol]+1, len[ol+ol+1]);
    		}
    		for (long long ujm1 = 0;ujm1 < tgb2;ujm1++){
    			rty('+', '-', len[ol+ol]+1, len[ol+ol+1]);
    		}
    	}
    	for (long long sgf = 0;sgf < dfs;sgf++){
    		rty('^', '^',0 , n.size());
    	}
    	for (long long qaz = 0;qaz < rfv;qaz++){
    		rty('*', '/',0 , n.size());
    	}
    	for (long long ujm = 0;ujm < tgb;ujm++){
    		rty('+', '-',0 , n.size());
    	}
    	cout << n << endl;
    	return 0;
    }
    //74358218459826983052456447818328434170069854277284839080710233456035947791137359812780069312117360707057608676103872279164478215533028367458638546011623687699399494874389150597148869779202188303019940029819529190979194219327077702182257942854243289783659726231034070131494515140721871985442452245173802752459443787278181026592171189353639181301552279863591260861982317079854122596292357216347956557549352162326680532751934199836594997169782234977172564254603948799275683194140099561482973312333254042507063999296737443510866408331937283867638274857895813750760860212010730008613722911725632804261481119336800280446215653034086887019755095191400590230708041749566156204899364884013462210880886021029110715447166618848807436555077629498643019255213329821242301532314735366968190995738393924823396451729956207731965410619805315387486108969251608355218204851916186673266342940906934995217240209604634829996244314060476904260721178617163238355812897232536366375248134649404554730648912603381144050555645453827510015907099218907421267108561083416946035461658033339375854900091647035079498438516449362241073781855051260190108266430114746780185838603396588619406427615068139727459488124230031986416266000837347303247187244860569552121577754080546264786648353892674531484185645014764615685230663970596398587382227472874971041468538226803783006803181402574594880774054493141930890097236637532238747020204707472607218422375068972600060999620433523481304509505875581557633160559030418144778703828370464038410633213933890148388226696887491273275998074190461773637991676147872184635206023955134472331531533858727568775669870134945504123298568458149628832925554403468679368683787996667216937997537176042903334517734222365579991418141506976679430504554891618734347263450639700648960674114557829328806152705491979432779724482110429857689232308299716104851128282428550372797478609491220392969681685081931511355576321268840592289752021807597963035064305245004649666016723241085026718682478621749045377210001262248336974547420919261264232428418904942082904526992842241208213073876301876926404810316793518126783864500123372636403503679923747048269352471162771174287361679340236874772138047831028857970261591591620029736957099148680234413642228491463161017413156350761110124415514517947919357586940942042785797677412461127304531332080430416101854567409422723720465792535332718328863285693349843335144977376223138963028707312372903467785871937972704251485144318965844480877866284571604198581997067922584377672152857218413479948381206663948654511538921243407088884253617286322241242951436512757207510885646922468634683675707306766380386114909720572616187197205942957766482888681040201178709142201064201501462449613847075019291119063196903842046353095554302071179792106706908145720615035931852459504826462051301424809754010964348275380012711447440747000363835716317784822150425196617373180019327279851762711385277245700624855218672646704195093675848256774205119008264235186244156086604707567965702511039787754492346140832282896132669647743410582225731392938981367036563623993885606144170603323246754724565985969053432181094498195719800920636171060208572966163196929556320412731283662780659971519356587756287836161935851497426412468630732026738623111199106350964778567501340219017388472505983494804232846479424180447606956241930844332037861746210036637289722787357677613535616967737262664959573931706881059956109584249818644291096567476596136821435587297281904150514274655602151702509188271581837692007932812419642236633952275452735145359233874725999248549447520326516007901411679794911685316944317492738667965429690467912046224728347667679258873166217090946606126592934878852112730214515330774216913725492334716463370226076261975715287811687415379089113193901968197228417920961507112968167883332994694868405895056152022440256952759463557517199134608207907456871400859930297257887791160968813544882457807279602751600227691461822450026638636685625525656443200760021840219379297699182775019661034602398454413350324979875005755705833942635967840192141226476542548942314767275959506136518703682725639862346177211079832302841838857032951116440598480357498789176935171055612905538500825597028741085061949761652325247027375239001590935163262954752766467435812574131853971288755726899755788491612556136071973319376449302810397238610283985245549237295086364989023750165843361803243935015972900386529497866071872107001603971001827382598936793809818504456662192602716190628998856319293603280801682055152843716427181894886672558874025375943234941336120199292660380418684892483865678725963486580197669664636113547890583671428631344189538545822612837598177787241773997997275742684125187036092910384517715935107561251033833995000315307706708012316901324974860309824217082994397819515134230281112205000268683932898065646998506607583587675634279261804471524235700350941802709625904074437194214618545187174485528656073646276275801045631056291609719217585812872670155525586944
    > ```
    
  • 通过的题目

  • 最近活动

    This person is lazy and didn't join any contests or homework.
  • 最近编写的题解

    This person is lazy and didn't write any solutions.
  • Stat

  • Rating

题目标签

系统测试
1
搜索
1
深度优先搜索
1
DFS
1
USACO
1