2024/07/14模拟赛总结
fly_bamboo · · 个人记录
呜呜呜,大型翻车现场(不忍直视
P8748
源代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
int sm;
cin>>sm;
int h=sm/3600000;
sm-=h*3600000;
int f=sm/60000;
sm-=f*60000;
int s=sm/1000;
if(h<10)
{
if(h==0) cout<<"00";
else cout<<"0"<<h;
}
else cout<<h;
cout<<":";
if(f<10)
{
if(f==0) cout<<"00";
else cout<<"0"<<f;
}
else cout<<f;
cout<<":";
if(s<10)
{
if(s==0) cout<<"00";
else cout<<"0"<<s;
}
else cout<<s;
return 0;
}
难受,我怎么不知道
以后认真审题T_T
正确代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
int sm;
cin>>sm;
sm%=86400000;
int h=sm/3600000;
sm-=h*3600000;
int f=sm/60000;
sm-=f*60000;
int s=sm/1000;
if(h<10)
{
if(h==0) cout<<"00";
else cout<<"0"<<h;
}
else cout<<h;
cout<<":";
if(f<10)
{
if(f==0) cout<<"00";
else cout<<"0"<<f;
}
else cout<<f;
cout<<":";
if(s<10)
{
if(s==0) cout<<"00";
else cout<<"0"<<s;
}
else cout<<s;
return 0;
}
P2010
源代码:
#include<bits/stdc++.h>
using namespace std;
int my[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool runnian(int x)
{
if((x%4==0&&x%100!=0)||x%400==0)
{
return true;
}
return false;
}
bool hefa(int n,int y,int r)
{
if(runnian(y))
{
my[2]==29;
}
else
{
my[2]=28;
}
if(y>=1&&y<=12)
{
if(r>=1&&r<=my[y])
{
return true;
}
}
return false;
}
int main()
{
int a,b;
cin>>a>>b;
int year1=a/10000;
int year2=b/10000;
int cnt=0;
for(int i=year1;i<=year2;i++)
{
int y1=i%10*10+(i/10%10);
int r1=i/100%10*10+i/1000;
int temp=i*10000+y1*100+r1;
if(hefa(i,y1,r1))
{
if(temp>=a&&temp<=b)
{
cnt++;
}
}
}
cout<<cnt;
return 0;
}
其实判断条件要把
如果不改会错失一次回文日期
总结:考虑不周到T_T
P1029
拿捏不讲
P5661
说实话,这道题已经
未调出......
P1332
原来的
改为多个点的广搜,上
#include<bits/stdc++.h>
using namespace std;
int n,m,k,b;
int l_x[1000005],l_y[1000005];
int k_x[1000005],k_y[1000005];
bool vis[1005][1005];
int ans[1005][1005];
struct node
{
int x,y,step;
}q[1000005];
int tail=1,head=0;
bool check(int x,int y)
{
if(x<1||x>n||y<1||y>m||vis[x][y]==true) return false;
else return true;
}
void work(int x,int y,int step)
{
if(check(x,y)==true)
{
head++;
q[head].x=x;
q[head].y=y;
q[head].step=step;
vis[x][y]=true;
ans[x][y]=step;
}
}
void bfs()
{
head+=k;
for(int i=1;i<=k;i++)
{
q[i].x=k_x[i];
q[i].y=k_y[i];
q[i].step=0;
ans[k_x[i]][k_y[i]]=0;
vis[k_x[i]][k_y[i]]=true;
}
while(head-tail+1>0)
{
int x=q[tail].x;
int y=q[tail].y;
int step=q[tail].step;
tail++;
work(x-1,y,step+1);
work(x+1,y,step+1);
work(x,y-1,step+1);
work(x,y+1,step+1);
}
}
int main()
{
cin>>n>>m>>k>>b;
for(int i=1;i<=k;i++)
{
cin>>k_x[i]>>k_y[i];
}
for(int i=1;i<=b;i++)
{
cin>>l_x[i]>>l_y[i];
}
bfs();
for(int i=1;i<=b;i++)
{
cout<<ans[l_x[i]][l_y[i]]<<endl;
}
return 0;
}
P1011
暴力思想
未调出......
总结:特别有进步空间,阅读理解不行了T_T