藍橋杯 第四講 列舉 模擬與排序

2022-09-19 20:42:13 字數 2675 閱讀 6195

#include #include #include using namespace std;

const int n = 10005;

int a[n],n,ans;

int max,min;

int main()

for(int i=1;i<=n;i++)//兩重迴圈算最值

注意:此處不同與模板二分,此處找的是小於或大於b[j]的第乙個數,而不是找它本身,二分迴圈裡無需出現等於號

#include #include #include using namespace std;

typedef long long ll;

const int n = 1e5+10;

int n,a[n],b[n],c[n];

ll ans;

int main()

if(a[l] >= x) continue;//找不到的話就列舉下乙個b數

//cout<1;

if(c[mid] > x) r = mid;

else l = mid + 1;

}if(c[l] <= x) continue;//找不到的話就列舉下乙個b數

//cout

typedef long long ll;

const int n = 1e5+10;

int n,a[n],b[n],c[n];

int cnt_a[n],cnt_b[n],cnt_c[n];//計數字首和,表示1~n中每個數出現的次數之和

ll ans;

int main()

;int ans;

int date1,date2;

bool isvalid(int date)

return true;

}int main()

if(isvalid(date)) ans++;//合法答案++

}cout把號碼都減去1,對映到0~n-1,模擬c++二維陣列表示法

#include #include #include using namespace std;

int w,m,n;

int main()

;void check(int yy,int mm,int dd)

if(yy%100==a && mm==b && dd==c || yy%100 == c && mm==b && dd == a || yy%100==c && mm==a && dd==b)

printf("%04d-%02d-%02d\n",yy,mm,dd);

}int main()

return 0;

}

#include #include #include #include using namespace std;

int t,h1,m1,s1,h2,m2,s2,d;

int h3,m3,s3,h4,m4,s4;

int time1,time2;

char str[100];

int main()

else sscanf(str,"%d:%d:%d %d:%d:%d (+%d)",&h1,&m1,&s1,&h2,&m2,&s2,&d);

time1 = d*24*3600 + h2*3600 + m2*60 + s2 - (h1*3600 + m1*60 + s1);

d = 0;

cin.getline(str,100);

if(strlen(str)==17)

else sscanf(str,"%d:%d:%d %d:%d:%d (+%d)",&h3,&m3,&s3,&h4,&m4,&s4,&d);

time2 = d*24*3600 + h4*3600 + m4*60 + s4 - (h3*3600 + m3*60 + s3);

int time = (time1+time2)/2;

printf("%02d:%02d:%02d\n",time/3600,(time%3600)/60,time%60);

}return 0;

}

1241. 外賣店優先順序

struct shop //表示1~n家店

shop[n];

struct bill

; }

sort(bill,bill + m);

for(int i=0;i5) shop[id].st = 1;//維護優先快取

shop[id].last = ts;//維護last

}for(int i = 1;i <= n;i++) //之前wa了好多次,問題就出在沒有處理last到t時刻的無訂單時的優先順序減法計算

}for(int i = 1;i <= n;i++)

cout<

return 0;

}

第四講 李群與李代數

1.當三維旋轉矩陣構成了特殊正交群so 3 兩個旋轉矩陣相乘表示做了兩次旋轉,對於這種只有乙個運算的集合,我們稱之為群 2.旋轉矩陣集合和矩陣乘法構成群,同樣變換矩陣和矩陣乘法也構成群 因此才能稱為旋轉矩陣群和變換矩陣群 3.每乙個李群都有對應的李代數 1 對於乙個旋轉矩陣與它的轉置的乘積為單位陣,...

第四講 深入介紹訊號與槽

本文概要 講解qt的訊號與槽機制,涉及訊號與槽的連線方法,連線條件等。可以使用訊號與槽機制的類 訊號與槽機制是在qobject類中實現的,這種機制能夠用與任何qobject子類中,但是應該在類 中加入q object巨集。槽的介紹 槽與普通的c 成員函式幾乎一樣 槽能夠被宣告為虛函式,能被過載,能夠...

SQL基礎第四講 分析函式之組內排序

sql基礎第四講 分析函式之組內排序 看python教程看的有點疲乏,還是寫點東西吧 為什麼說是簡講呢,其實分析函式在工作中用到的地方也是非常多的,但是它可以實現的方面有很多,這裡給大家講三方面 1.分組內排序 2.分組內求聚合 3.計算行與行資料之間的偏移量。ps 當你學會分析函式,相信我,你會愛...