题目连接
懵逼的签到题
#include
#define pb push_back//vector,deque
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=1e5+5;
void solve()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int res=n==0?1:0;
cout<
签到题
#include
#define pb push_back//vector,deque
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll q_pow(ll a,ll b)
{
ll res=1;
while(b){
if(b&1)res=res*a%1000;
a=a*a%1000;
b>>=1;
}
return res;
}
void solve()
{
ll n;
while(scanf("%lld",&n)!=EOF){
ll res=q_pow(5,n);
printf("%03lld\n",res);
}
}
int main() {
solve();
return 0;
}
/*
5
125
6
625
7
125
*/
实际上只需要把cnt(只有一个!!!)给踢出去,剩下求和取模即可。wa了好几发,最后发现是等于cnt的我全剔除出去了。
#include
#define pb push_back//vector,deque
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=2e6+5;
int a[N];
void solve()
{
int n,cnt;
while(scanf("%d%d",&n,&cnt)!=EOF){
int x,cot=0;
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
bool flag=true;
int res=0;
if(n==2){
if(a[1]==cnt)printf("%d\n",a[2]);
else printf("%d\n",a[1]);
continue;
}
for(int i=1;i<=n;i++){
if(flag&&a[i]==cnt){
a[i]=0;flag=false;
}
res+=a[i];
res%=11;
}
printf("%d\n",res);
}
}
int main() {
solve();
return 0;
}
签到题
#include
#define pb push_back//vector,deque
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=1e5+5;
string e[105];
struct node{
int x,y,step;
};
queueq;
int res=-1,dir[4][2]={0,1,1,0,0,-1,-1,0},vis[105][105];
void bfs(int ex,int ey,int n,int m)
{
while(q.size()){
node h=q.front();
q.pop();
if(h.x==ex-1&&h.y==ey-1){
res=h.step*100;
break;
}
for(int i=0;i<4;i++){
int xx=dir[i][0]+h.x;
int yy=dir[i][1]+h.y;
if(xx>=0&&xx=0&&yy>n>>m>>sx>>sy>>ex>>ey;
for(int i=0;i>e[i];
q.push({sx-1,sy-1,0});
vis[sx-1][sy-1]=1;
bfs(ex,ey,n,m);
cout<
最小生成树板子,不过需要注意的是先把字符串映射成节点数字。然后就行了。最后NO的情况实际就是cnt!=n-1。因为这样他走遍不了所有城市。
#include
#define pb push_back//vector,deque
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=4e5+5;
struct node{
int u,v;
ll val;
bool operator<(const node&other){//重载小于运算符
return val>n>>q){
unordered_mapmp;
string s,t;
cot=0;cnt=0;
ll val;
cin>>s;
mp[s]=++cot;
for(int i=0;i>s>>t>>val;
if(mp.count(s)==0)mp[s]=++cot;
if(mp.count(t)==0)mp[t]=++cot;
add(mp[s],mp[t],val);
}
for(int i=1;i<=n;i++)pre[i]=i;
ll res=0;
int edge=0;
sort(e+1,e+1+cnt);
for(int i=1;i<=cnt;i++){
int fx=find(e[i].u),fy=find(e[i].v);
if(fx==fy)continue;
pre[fx]=fy;
res+=e[i].val;
if(++edge==n-1)break;
}
if(edge==n-1)cout<