<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

       直接模擬即可,注意特判

      #include<iostream>
      #include<cstdio>
      #include<ctime>
      #include<cstdlib>
      #include<cmath>
      #include<cstring>
      #include<algorithm>
      #define maxn 200010
      #define LL long long
      using namespace std;
      
      int main()
      {
          int a,b;
          cin>>a>>b;
          if(a==1){
          	cout<<1;return 0;
      	}
      	if(b==1){
      		cout<<a;return 0;
      	}
      	LL ans=1;
      	while(b&&ans<=1e9){
      		ans*=a;
      		b--;
      	}
      	if(ans>1e9){
      		cout<<-1;return 0;
      	}
      	cout<<ans;
      	return 0;
      }

      其實(shí)就是數(shù)學(xué)題,解方程而已,也可以二分因?yàn)閜<q

      #include<iostream>
      #include<cstdio>
      #include<ctime>
      #include<cstdlib>
      #include<cmath>
      #include<cstring>
      #include<algorithm>
      #define maxn 200010
      #define LL long long
      using namespace std;
      //這道題可以用二分,也可以直接帶進(jìn)去式子算(一元二次方程  帶公式,看算的出來(lái)不)
       
      int main()
      {
      	LL k,n,e,d,p,q;
      	cin>>k;
      	while(k--){
      		cin>>n>>e>>d;
      		LL delta=sqrt((n-e*d+2)*(n-e*d+2)-4*n);
      		LL b=n-e*d+2;
      		LL p=(b+delta)/2;
      		LL q=b-p;
      		if(p*q==n&&e*d==(p-1)*(q-1)+1&&p&&q){
      			cout<<min(p,q)<<" "<<max(p,q)<<endl;
      		}
      		else cout<<"NO"<<endl;
      	}
      	return 0;
      }

       用棧把中綴轉(zhuǎn)后綴表達(dá)式,在加上一些巧妙地操作。。。

       

      #include<iostream>
      #include<cstring>
      #include<cmath>
      #include<algorithm>
      #include<stack>
      #include<cstdio>
      #include<queue>
      #include<map>
      #include<ctime>
      #include<vector>
      #include<set>
      using namespace std;
      typedef long long LL;
      const int maxn=1e6+10;
      using namespace std;
      //表達(dá)式求值:后綴表達(dá)式
      //但是有其他巧妙地操作:統(tǒng)計(jì)略過(guò)的計(jì)算次數(shù) (短路)
      stack<int> st;
      stack<pair<int,int> > duan;  //短路或、與的次數(shù)
      string s;
      stack<char> op;
      map<char,int> mp; //運(yùn)算符優(yōu)先級(jí)的 
      void merg_duan(pair<int,int> aa,pair<int,int> bb,int a,int b,char p){
      	//如果 a|b  a為1,那么或短路次數(shù)為a.first+1   與為aa.second 
      	//如果a為0 那么就是aa+bb
      	pair<int,int> c;
      	if(a==1&&p=='|'){
      		c.first=aa.first+1;
      		c.second=aa.second;
      	} 
      	//如果 a&b  a為0,那么或次數(shù)不變,與次數(shù)+1 
      	else if(a==0&&p=='&'){
      		c=aa;
      		c.second++;
      	} 
      	else{
      		c.first=aa.first+bb.first;
      		c.second=aa.second+bb.second;
      	}
      	duan.push(c); //把新的短路次數(shù)也加入 
      }
      void calc(){
      	int b=st.top();st.pop();
      	int a=st.top();st.pop();
      	int num=0;
      	pair<int,int> bb=duan.top();duan.pop();
      	pair<int,int> aa=duan.top();duan.pop();
      	merg_duan(aa,bb,a,b,op.top());
      	if(op.top()=='|') num=a|b;
      	else if(op.top()=='&') num=a&b;
      	st.push(num);
      	op.pop();
      	return; 
      	
      }
      void solve(){
      	int len=s.length();
      	for(int i=0;i<len;i++){
      		if(isdigit(s[i])) st.push(s[i]-'0'),duan.push({0,0});
      		//遇到數(shù)字,就入棧,數(shù)字和短路次數(shù)
      		else{
      			if(s[i]=='(') op.push('(');
      			if(s[i]==')'){
      				while(!op.empty()&&op.top()!='(') calc();
      				if(!op.empty()) op.pop(); //把(彈出去 
      			}
      			if(s[i]!='('&&s[i]!=')'){
      				//如果遇到運(yùn)算符,就先把棧里面優(yōu)先級(jí)高的都彈出 
      				while(!op.empty()&&mp[op.top()]>=mp[s[i]]) calc();
      				op.push(s[i]);
      			}
      		} 
      	}
      	while(!op.empty()){
      		calc();
      	}
      	cout<<st.top()<<endl<<duan.top().second<<" "<<duan.top().first<<endl;
      }
      int main(){
      	cin>>s;
      	mp['&']=2;
      	mp['|']=1;	
      	solve();
      	return 0;
      }
      

        

       典型的dp

      f[i][j]表示走到i,用了插入的j個(gè)點(diǎn)能取到的最大值

      #include <bits/stdc++.h>
      using namespace std;
      const int maxn=505;
      int f[maxn][maxn];   //f[i][j]: 前 i 個(gè)點(diǎn),插入了 j 個(gè)點(diǎn)后最大長(zhǎng)度
      pair<int,int> a[maxn];
      int main()
      {
      	int n,k;
      	cin>>n>>k;
      	for(int i=1;i<=n;i++) cin>>a[i].first>>a[i].second;
      	sort(a+1,a+1+n);
      	for(int i=1;i<=n;i++){
      		for(int j=0;j<=k;j++) f[i][j]=1+j;
      	}
      	//最長(zhǎng)上升子序列
      	for(int i=2;i<=n;i++){
      		for(int j=i-1;j>=1;j--){
      			if(a[j].second>a[i].second) continue;
      			//從j到i要插入d個(gè)點(diǎn)
      			int d=a[i].first-a[j].first+a[i].second-a[j].second-1;
      			for(int p=d;p<=k;p++) f[i][p]=max(f[i][p],f[j][p-d]+1+d); 
      		}
      	} 
      	int ans=0;
      	for(int i=1;i<=n;i++) ans=max(ans,f[i][k]);
      	cout<<ans<<endl;
      	return 0;
      }
      

        

       posted on 2023-11-01 14:32  shirlybabyyy  閱讀(22)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 国产综合久久99久久| 亚洲国产美国产综合一区| 桃花岛亚洲成在人线AV| 99热这里有精品| 国产一区二区在线观看粉嫩| 激情久久av一区二区三区| 2020中文字字幕在线不卡| 亚洲午夜性猛春交xxxx| 欧美日韩精品一区二区在线观看| 亚洲中文字幕一区二区| 人人澡人人妻人人爽人人蜜桃 | 激情综合网激情五月我去也| 91毛片网| 亚洲另类激情专区小说图片| 国产一区二区三区色噜噜| 人妻丰满熟妇AV无码区乱| 久久久久无码精品国产h动漫| 亚洲美女少妇偷拍萌白酱| 精品国产亚洲第一区二区三区| 白嫩少妇无套内谢视频| 国产成人高清亚洲综合| 国产成人亚洲综合图区| 国产精品亚洲二区亚瑟| 午夜福利国产一区二区三区| 亚洲青青草视频在线播放| 欧美丰满熟妇乱XXXXX网站| 国产高清视频一区二区乱| 一道本AV免费不卡播放| 日韩精品无码免费专区午夜不卡| 亚洲爆乳WWW无码专区| 国产精品永久久久久久久久久| 亚洲成a人无码av波多野| 强奷乱码中文字幕| 漂亮的保姆hd完整版免费韩国| 亚洲理论在线A中文字幕| 免费看视频的网站| 中文字幕在线亚洲日韩6页| 国精偷拍一区二区三区| 国产成人综合色在线观看网站| 免费一区二三区三区蜜桃| 国产啪视频免费观看视频|