Codeforces Round 493

心情不好,被遣散回學校 ,心態不好 ,為什么會累,一直微笑就好了

#include<bits/stdc++.h>
using namespace std;
int main()
{freopen("in","r",stdin);\freopen("out","w",stdout);int n ,k=0,s=0,a[10];cin>>n;for(int i=0;i<n;i++){cin>>a[i];if(a[i]<a[k]) k=i;s+=a[i];}if(n<2||a[k]==s-a[k]){cout<<-1;}else{cout<<1<<" "<<k+1<<endl;} 
}
View Code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = (int)1e4+5;
ll arr[maxn],n,k;
int main()
{cin>>n>>k;for(int i=0;i<n;i++) cin>>arr[i];ll num1=0 ,num2=0;vector<long long> v;for(int i=0;i<n-1;i++){if(arr[i]&1)num1++;else num2++;if(num1    == num2) v.push_back(abs(arr[i]-arr[i+1]));}ll s= 0,ans=0;if(v.size()==0) cout<<0<<endl;else{sort(v.begin(),v.end());for(int i=0;i<v.size();i++){s+=v[i];if(s>k)break;ans++;}cout<<ans<<endl;}}
View Code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{freopen("in","r",stdin);\freopen("out","w",stdout); string str;ll n,m,k;cin>>n>>m>>k>>str;vector<int> v;int ans=0;if(str[0]=='0')ans =1;for(int i=1;i<n;i++){if(str[i]=='0'&&str[i-1]!='0') ans++;}ll cnt = LLONG_MAX;for(int i=0;i<ans;i++){cnt = min(cnt,m*i+k*(ans-i));}cout<<(cnt==LLONG_MAX?0:cnt) <<endl;
}
View Code
#include<bits/stdc++.h>
using namespace std;
#define REP(i,l,r) for(int i=l;i<=r;i++)
int main()
{set<long long> s;long long n;cin>>n;if(n<=10){REP(i,0,n) REP(j,0,n)REP(k,0,n)REP(l,0,n){if(i+j+k+l==n) s.insert(50*l+10*k+5*j+i);}cout<<s.size()<<endl;}else cout<<49ll*n-247<<endl;
}
View Code
#include<iostream>using namespace std;typedef long long ll;const ll mod = 998244353;ll pow(ll a, ll b) {ll ans = 1;while (b) {if (b & 1) {ans = ans * a % mod;}b >>= 1;a = a * a % mod;}return ans;
}int main() {ll n ;cin>>n;ll ans =0,cur= 1;for(int i=1;i<=n;i++){cur = cur*(n+1-i)*pow(i,mod-2);ll sign = pow(-1,i+1);ll val = pow(3,i)*pow(3,n*(n-i));ans = ans+(cur*sign*val);}ans = ans*2;cur =1 ;#if 0{cur = cur * (N + 1 - i) % mod * pow(i, mod - 2) % mod;ll sign = pow(-1, i + 1);ll val = pow(3, i) * pow(3, N * (N - i)) % mod;ans = (ans + (cur * sign * val) % mod) % mod;}ans = ans * 2 % mod;cur = 1;for (int i = 0; i < N; ++i) {ll sign = pow(-1, i + 1);ll val = (pow(-pow(3, i) + 1, N) - (pow(-pow(3, i), N))) % mod * 3 % mod;ans = (ans + cur * sign * val % mod) % mod;cur = cur * (N - i) % mod * pow(i + 1, mod - 2) % mod;}ans = (ans + mod) % mod;cout << ans << endl;return 0;#endif 
}
View Code
 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353 ;
ll ans,n;
ll q_pow(ll x,ll y)
{ll ans =1;while(y){if(y&1) ans = ans*x%mod;x=x*x%mod;y>>=1;}return ans;
}
int main()
{cin>>n;ans  = q_pow(3,n*n) - q_pow(q_pow(3,n)-3,n);for(ll i =0 ,t=1;i<=n;i++){ll b = q_pow(3,n-i);ll res = t*(q_pow(b,n) - q_pow(b-(i?1:3)+mod,n))%mod;if(i) res = res*3%mod;ans+=i&1?-res:res;t =t*(n-i)%mod*q_pow(i+1,mod-2)%mod;}cout<<(ans%mod+mod)%mod;
}
View Code
#include<bits/stdc++.h>
using namespace std; 
using namespace std;typedef long long ll;const int N = 4010, K = 80, P = 998244353;int k;
int comb[K][K];
int a1[K], a2[K];
pair<int, int> t1[N], t2[N];void solve(int n, pair<int, int>* t, int* a);int main() {int n, m;scanf("%d%d%d", &n, &m, &k);if (k % 2) {puts("0");return 0;}k /= 2;for (int i = 1; i < n; ++i)scanf("%d%d", &t1[i].first, &t1[i].second);for (int i = 1; i < m; ++i)scanf("%d%d", &t2[i].first, &t2[i].second);solve(n, t1, a1);solve(m, t2, a2);for (int i = 0; i <= k * 2; ++i) {comb[i][0] = 1;for (int j = 1; j <= i; ++j) {comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];if (comb[i][j] >= P)comb[i][j] -= P;}}int ans = 0;for (int i = 0; i <= k; ++i)ans = (ans + (ll)comb[k * 2][i * 2] * a1[i] % P * a2[k - i] % P) % P;printf("%d\n", ans);return 0;
}void solve(int n, pair<int, int>* t, int* a) {static int dp[K][N * 3], sum[K][N];memset(dp, 0, sizeof(dp));memset(sum, 0, sizeof(sum));for (int i = 0; i <= n * 3 - 2; ++i)dp[0][i] = 1;for (int i = 1; i <= k; ++i) {for (int e = 1; e < n; ++e) {int u = t[e].first, v = t[e].second;sum[i - 1][u] += dp[i - 1][n * 2 - 1 + e];if (sum[i - 1][u] >= P)sum[i - 1][u] -= P;sum[i - 1][v] += dp[i - 1][n + e];if (sum[i - 1][v] >= P)sum[i - 1][v] -= P;}for (int j = 0; j < i; ++j) {for (int e = 1; e < n; ++e) {int u = t[e].first, v = t[e].second;dp[i][u] = (dp[i][u] + dp[j][u] * (ll)dp[i - j - 1][n * 2 - 1 + e]) % P;dp[i][v] = (dp[i][v] + dp[j][v] * (ll)dp[i - j - 1][n + e]) % P;dp[i][n + e] = (dp[i][n + e] + dp[j][n + e] * (ll)(sum[i - j - 1][u] - dp[i - j - 1][n * 2 - 1 + e]) % P + P) % P;dp[i][n * 2 - 1 + e] = (dp[i][n * 2 - 1 + e] + dp[j][n * 2 - 1 + e] * (ll)(sum[i - j - 1][v] - dp[i - j - 1][n + e]) % P + P) % P;}}}for (int i = 0; i <= k; ++i) {for (int u = 1; u <= n; ++u) {a[i] += dp[i][u];if (a[i] >= P)a[i] -= P;}}
}
View Code
這個真的沒有心情切掉,看看詭異的算法
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){static char buf[100000],*p1=buf,*p2=buf;return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){ll x = 0; char ch = gc(); bool positive = 1;for (; !isdigit(ch); ch = gc())    if (ch == '-')    positive = 0;for (; isdigit(ch); ch = gc())    x = x * 10 + ch - '0';return positive ? x : -x;
}
inline void write(ll a){if(a<0){a=-a; putchar('-');}if(a>=10)write(a/10);putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=120005,block=300,B=N/block+3,inf=1000000005;
int n,q,a[N],belong[N],mzs[N],p[N],l[N],r[N],q1[N],q2[N],t1,t2,val[N],cnt[B],lazy[B],L[B],R[B];
PI mn[N];
ll ans[N];
PI operator +(PI a,PI b){if(a.second==0)return b; else if(b.second==0)return a;return a.first==b.first?mp(a.first,a.second+b.second):(a.first>b.first?a:b);
}
void bao(int l,int r,int x){//cout<<l<<" "<<r<<" "<<x<<endl;int id=belong[l];for(int i=l;i<=r;i++)a[i]+=x;mn[id]=mp(inf,0); for(int i=L[id];i<=R[id];i++)mn[id]=mn[id]+mp(a[i],1);
}
void down(int x){if(!mzs[x])return;for(int i=L[x];i<=R[x];i++)if(a[i]==mn[x].first){val[i]+=mzs[x];}mzs[x]=0;
}
void ins(int l,int r,int x){if(l>r)return;if(belong[l]==belong[r]){down(belong[l]); bao(l,r,x); return;}down(belong[l]); bao(l,R[belong[l]],x);down(belong[r]); bao(L[belong[r]],r,x);for(int i=belong[l]+1;i<belong[r];i++)lazy[i]+=x;
}
void upd(){for(int i=1;i<=belong[n];i++)if(mn[i].first+lazy[i]==0){mzs[i]++; cnt[i]+=mn[i].second;}
}
ll ask(int l){ll ans=0; down(belong[l]);for(int i=l;i<=R[belong[l]];i++)ans+=val[i];for(int i=belong[l]+1;i<=belong[n];i++)ans+=cnt[i];return ans;
}
vector<int> v[N];
int main(){n=read();for(int i=1;i<=n;i++){p[i]=read();if((i-1)%block==0)L[belong[i]=belong[i-1]+1]=i; else belong[i]=belong[i-1];R[belong[i]]=i;a[i]=-1; mn[belong[i]]=mn[belong[i]]+mp(-1,1);}q=read();for(int i=1;i<=q;i++){l[i]=read(); r[i]=read();v[r[i]].push_back(i);}for(int i=1;i<=n;i++){while(p[q1[t1]]<p[i]&&t1){ins(q1[t1-1]+1,q1[t1],-p[i]+p[q1[t1]]); t1--; }q1[++t1]=i;while(p[q2[t2]]>p[i]&&t2){ins(q2[t2-1]+1,q2[t2],p[i]-p[q2[t2]]); t2--;}q2[++t2]=i;ins(1,i,1); upd();//for(int i=1;i<=n;i++)cout<<a[i]<<" "; puts("");//cout<<mzs[1]<<" "<<mn[1].first<<" szb"<<lazy[1]<<" "<<cnt[2]<<" "<<endl;for(unsigned j=0;j<v[i].size();j++)ans[v[i][j]]=ask(l[v[i][j]]);}for(int i=1;i<=q;i++)writeln(ans[i]);
} 
View Code

?

轉載于:https://www.cnblogs.com/corx/p/9288715.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/389192.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389192.shtml
英文地址,請注明出處:http://en.pswp.cn/news/389192.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

android動畫筆記二

從android3.0&#xff0c;系統提供了一個新的動畫&#xff0d;property animation, 為什么系統會提供這樣一個全新的動畫包呢&#xff0c;先來看看之前的補間動畫都有什么缺陷吧1、傳統的補間動畫都是固定的編碼&#xff0c;功能是固定的&#xff0c;擴展難度大。比如傳統動畫只…

回歸分析檢驗_回歸分析

回歸分析檢驗Regression analysis is a reliable method in statistics to determine whether a certain variable is influenced by certain other(s). The great thing about regression is also that there could be multiple variables influencing the variable of intere…

是什么樣的騷操作讓應用上線節省90%的時間

優秀的程序員 總會想著 如何把花30分鐘才能解決的問題 在5分鐘內就解決完 例如在應用上線這件事上 通常的做法是 構建項目在本地用maven打包 每次需要clean一次&#xff0c;再build一次 部署包在本地ide、git/svn、maven/gradie 及代碼倉庫、鏡像倉庫和云平臺間 來回切換 上傳部…

QQ API

QQ API設計說明書目錄一、引言 31.1 編寫目的 31.2 更新時間 3二、總體設計 3三、注冊的系統消息 33.1 WM_QQAPI_REGISTER 33.2 WM_QQAPI_REGISTER_RESP 43.3 WM_QQAPI_AVAILABLE 4四、從設備到QQ的自定義事件 54.1 EVENT_QQAPI_SET_AUDIODEVICE …

Ubuntu 18.04 下如何配置mysql 及 配置遠程連接

首先是大家都知道的老三套&#xff0c;啥也不說上來就放三個大招&#xff1a; sudo apt-get install mysql-serversudo apt isntall mysql-clientsudo apt install libmysqlclient-dev 這三步下來mysql就裝好了&#xff0c;然后我們偷偷檢查一下 sudo netstat -tap | grep mysq…

數據科學與大數據技術的案例_主數據科學案例研究,招聘經理的觀點

數據科學與大數據技術的案例I’ve been in that situation where I got a bunch of data science case studies from different companies and I had to figure out what the problem was, what to do to solve it and what to focus on. Conversely, I’ve also designed case…

導致View樹遍歷的時機

遍歷View樹意味著整個View需要重新對其包含的子視圖分配大小并重繪&#xff0c;導致重新遍歷的原因主要有三個 1.視圖本身內部狀況變化引起重繪。 2.第二個是View樹內部添加或者刪除了View。 3.View本身的大小及可見性發生變化。 能引起View樹重新遍歷的操作&#xff0c;總…

什么是Hyperledger?Linux如何圍繞英特爾的區塊鏈項目構建開放平臺?

訪問區塊鏈會議并關注區塊鏈新聞時&#xff0c;不可避免地&#xff0c;您會遇到Linux基金會的Hyperledger。理解像比特幣、以太坊這樣的加密貨幣還算相對容易的&#xff0c;Hyperledger卻不然。但如果你多研究研究&#xff0c;你會發現一些令人興奮的非貨幣、工業區塊鏈的應用項…

隊列的鏈式存儲結構及其實現_了解隊列數據結構及其實現

隊列的鏈式存儲結構及其實現A queue is a collection of items whereby its operations work in a FIFO — First In First Out manner. The two primary operations associated with them are enqueue and dequeue.隊列是項目的集合&#xff0c;由此其操作以FIFO(先進先出)的方…

安裝

、添加一個新項目->選擇類庫模板->命名為DBCustomAction 2、單擊項目右鍵->添加新項->選擇安裝程序類(命名為DBCustomAction.cs) 3、在 服務器資源管理器中添加->連接到 數據庫->指定用戶密碼(選擇允許保存密碼)-> 數據庫選擇master 4、切換到DBCustomAct…

cad2016珊瑚_預測有馬的硬珊瑚覆蓋率

cad2016珊瑚What’s the future of the world’s coral reefs?世界珊瑚礁的未來是什么&#xff1f; In February of 2020, scientists at University of Hawaii Manoa released a study addressing this very question. The models they developed forecasted a 70–90% worl…

EChart中使用地圖方式總結(轉載)

EChart中使用地圖方式總結 2018年02月06日 22:18:57 來源&#xff1a;https://blog.csdn.net/shaxiaozilove/article/details/79274772最近在仿照EChart公交線路方向示例&#xff0c;開發表示排水網和污水網流向地圖&#xff0c;同時地圖上需要疊加排放口、污染源、污水處理廠等…

android mvp模式

越來越多人討論mvp模式&#xff0c;mvp在android應用開發中獲得更多的重視&#xff0c;這里說一下對MVP的簡單了解。 什么是 MVP? MVP模式使邏輯從視圖層分開&#xff0c;目的是我們在屏幕上怎么表現&#xff0c;和界面如何工作的所有事情就完全分開了。 View顯示數據&…

Node.js REPL(交互式解釋器)

2019獨角獸企業重金招聘Python工程師標準>>> Node.js REPL(交互式解釋器) Node.js REPL(Read Eval Print Loop:交互式解釋器) 表示一個電腦的環境&#xff0c;類似 Window 系統的終端或 Unix/Linux shell&#xff0c;我們可以在終端中輸入命令&#xff0c;并接收系統…

中國移動短信網關CMPP3.0 C#源代碼:使用示例

中國移動短信網關CMPP3.0 C#源代碼&#xff1a;使用示例 中國移動短信網關CMPP3.0 C#源代碼使用&#xff0c;在上一篇文章中我介紹過cmpp3.0,這段時間因為也做關于移動短信網關的開發&#xff0c;在這里給大家一個演示如何使用cmpp3.0開發移動短信網關。Using Tiray.SMS... Ti…

用python進行營銷分析_用python進行covid 19分析

用python進行營銷分析Python is a highly powerful general purpose programming language which can be easily learned and provides data scientists a wide variety of tools and packages. Amid this pandemic period, I decided to do an analysis on this novel coronav…

名稱

命名規則&#xff1a;Go中函數、變量、常量、類型、語句標簽和包的名稱都遵循一個規則&#xff0c;開頭是一個字母或下劃線&#xff0c;后面跟任意字符、數字和下劃線&#xff0c;并區分大小寫。例如&#xff1a;heapSort和HeapSort是不同名稱。關鍵字&#xff1a;Go有25個關鍵…

Alpha沖刺第二天

Alpha第二天 1.團隊成員 鄭西坤 031602542 &#xff08;隊長&#xff09; 陳俊杰 031602504陳順興 031602505張勝男 031602540廖鈺萍 031602323雷光游 031602319蘇芳锃 0316023302.項目燃盡圖 3.項目進展 時間工作內容11月18日UI設計、初步架構搭建11月19日UI設計、服務器的進一…

Tiray.SMSTiray.SMSTiray.SMSTiray.SMSTiray.SMSTiray.SMS

這是2005年6月云南移動短信網關升級到3.0時寫的&#xff0c;在SP那穩定運行了很長時間的。因為SP倒閉了&#xff0c;貼出來給有興趣的朋友參考。優點&#xff1a;支持多線程、滑動窗口、異步發送、全事件模式、自動識別ASCII、GBK、UCS-2缺點&#xff1a;不支持長短信自動分頁、…

水文分析提取河網_基于圖的河網段地理信息分析排序算法

水文分析提取河網The topic of this article is the application of information technologies in environmental science, namely, in hydrology. Below is a description of the algorithm for ranking rivers and the plugin we implemented for the open-source geographic…