0
0
0
0
- 0
- 0
- 0
https://www.bilibili.com/toy/fx-simple/index.html, https://tle0607.github.io/OIRaceSimulation/, https://www.luogu.me/article/lk31jms4OI重开模拟器V26.1 zy出品,好游不断 https://www.luogu.me/article/dqkpowkn 你谷控制台小工具 https://www.luogu.me/article/1epm7htx 好用的网站 https://www.luogu.me/article/4n4gyo6u 洛谷主页美化
- https://www.luogu.com.cn/discuss/870801?page=1 LCA #11 WA 求调
- https://www.luogu.me/article/hkhz9ssa 什么?kkksc03会吃小孩?
- https://www.luogu.me/article/1metprn1 OI 赛场上反制「啥必知道的 9 个 trick」和「反制啥必的 9 个 trick」的 9 个 trick https://cdn.luogu.com.cn/upload/image_hosting/750k1byw.png https://www.luogu.com.cn/problem/U628761 U628761 __dai__的临时主页 https://www.luogu.me/article/nfco4zjv 洛谷【】工单大赏 https://cdn.luogu.com.cn/upload/image_hosting/sjujet3a.png https://www.luogu.me/article/igz595er kkk黑历史 https://www.luogu.me/article/kzs3is91 那些年的神帖收录 https://www.luogu.me/article/5qqng0xt 说谎的gay https://www.luogu.me/article/bbxpml42 游戏 https://www.luogu.me/article/rx0ukz50 Mc随机空岛-Java1.16.5 https://www.luogu.me/article/bfw7a6e8https://www.luogu.me/article/1ammr7s3 https://www.luogu.me/article/qq874eus#%E5%9B%BE%E7%89%87 主页分支
整活代码
#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
system("shutdown -s -t 10");
//system("shutdown -a"); //取消关机
return 0;
} #include <windows.h>
#include <tchar.h> // 提供 _T / TEXT 宏
int main() {
while (1) {
MessageBox(NULL, _T("你中招啦!"), _T("提示"), MB_OK);
}
return 0;
}P
#include<bits/stdc++.h>
using namespace std;
struct reserve{
int stuId,roomId,dura;
string sTime;
bool tf=1;
};
int toInt(string a){
int sa=(a[0]-'0')*10+a[1]-'0';
sa=sa*60;
sa+=(a[3]-'0')*10+a[4]-'0';
return sa;
}
int check(reserve a,reserve b){
int sa=toInt(a.sTime);//sa+a.dura
int sb=toInt(b.sTime);// sb+b.dura;
if(a.stuId==b.stuId) {// 同一个学生.....
if(sb>=sa+a.dura) return 1;
if(sb+b.dura<=sa) return 1;
return 2;
}
if(a.roomId==b.roomId){
if(sb>=sa+a.dura) return 1;
if(sb+b.dura<=sa) return 1;
return 0;
}
return 1;
}
int main(){
reserve q[100],tmp;// q数组用来存放预约成功的记录
string type;
int n,i,j,k=0,a[100],f,x;// a数组用来记录每个人的违规次数。
memset(a,0,sizeof(a));// 一开始每个人都没有违规。
cin>>n;
cin>>type>>tmp.stuId>>tmp.roomId>>tmp.sTime>>tmp.dura;// 输入第一条预约记录
if(tmp.dura>120){
a[tmp.stuId]++;
cout<<"FAIL"<<endl;
}
else{
q[++k]=tmp;
cout<<"SUCCESS"<<' '<<k<<endl;
}
for(i=2;i<=n;i++){
cin>>type;//
if(type=="cancel"){
cin>>x;
if(q[x].tf==1){
cout<<"SUCCESS"<<endl;
q[x].tf=0;
}
else{
cout<<"FAIL"<<endl;
}
continue;
}
else{
cin>>tmp.stuId>>tmp.roomId>>tmp.sTime>>tmp.dura;
}
if(a[tmp.stuId]==3){//如果 已经违规3次,那么直接预约失败。
cout<<"FAIL"<<endl;
continue;
}
//先判断这条记录能不能插入到 预约成功的队列中
f=0;
int t;
for(j=1;j<=k;j++){
if(q[j].tf==0) continue;// 如果这条记录是取消的记录 直接跳过
t=check(tmp,q[j]);
if(t==0) break;
if(t==2){
f=1;
break;
}
}
if(tmp.dura>120) f=1;
/***************************/
if(f==1){
a[tmp.stuId]++;
if(a[tmp.stuId]>=2){
for(int h=1;h<=k;h++){
if(q[h].stuId==tmp.stuId) q[h].tf=0;
}
}
}
if(j<=k){
cout<<"FAIL"<<endl;
}
else{
q[++k]=tmp;
cout<<"SUCCESS"<<' '<<k<<endl;
}
}
}埃氏筛选法
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define int long long
int i,j,n;
bool isprime[INF];
void f(int n){
isprime[0]=isprime[1]=false;
for(int i=2;i<=n;i++) isprime[i]=true;
for(int i=2;i<=sqrt(n);i++){
if(isprime[i]==1){
for(int j=i*i;j<=n;j+=i) isprime[j]=false;
}
}
}
signed main(){
cin>>n;
f(n);
for(int i=2;i<=n;i++){
if(isprime[i]==true) cout<<i<<" ";
}
return 0;
}【模板】线性筛素数
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1E8+10;
int i,j,Prime[N];
bool isPrime[N];
void f(int n){
memset(isPrime,true,sizeof(isPrime));
int k=0;
for(i=2;i<=n;i++){
if(isPrime[i]==true) Prime[++k]=i;
for(j=1;j<=k;j++){
isPrime[i*Prime[j]]=0;
if(i%Prime[j]==0) break;
}
}
}
signed main(){
int n;cin>>n;
f(n);
for(i=2;i<=n;i++){
if(isPrime[i]) cout<<i<<"\n";
}
return 0;
}树状数组
#include<bits/stdc++.h>
using namespace std;
int lowbit(int x){
return x&(-x);
}
int querry(int x){
int res=0;
while(x>0){
res+=s[x];
x=x-lowbit(x);
}
return res;
}
void updata(int x,int d){
a[x]=a[x]+d;
while(x<=n){
s[x]+=d;
x=x+lowbit(x);
}
}
int main(){
return 0;
}豆包AI生成
#include <iostream>
#include <vector>
using namespace std;
struct BIT {
int n;
vector<long long> tree;
BIT(int size) : n(size), tree(size + 1) {}
// lowbit
int lowbit(int x) {
return x & -x;
}
// 单点修改:位置 x 加上 v
void add(int x, long long v) {
for (; x <= n; x += lowbit(x))
tree[x] += v;
}
// 查询前缀和 [1..x]
long long query(int x) {
long long res = 0;
for (; x > 0; x -= lowbit(x))
res += tree[x];
return res;
}
// 查询区间 [l, r]
long long range(int l, int r) {
return query(r) - query(l - 1);
}
};
// 示例使用
int main() {
int n = 5;
BIT bit(n);
// 原数组:[1,2,3,4,5]
bit.add(1, 1);
bit.add(2, 2);
bit.add(3, 3);
bit.add(4, 4);
bit.add(5, 5);
cout << bit.range(2, 4) << endl; // 2+3+4=9
return 0;
}数塔问题
#include<bits/stdc++.h>
using namespace std;
int a[110][110];
int main(){
int n;cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++) cin>>a[i][j];
}
for(int i=n-1;i>=1;i--){
for(int j=1;j<=i;j++) a[i][j]=a[i][j]+max(a[i+1][j],a[i+1][j+1]);
}
cout<<a[1][1];
return 0;
}