Acwing.第121场周赛
比赛链接
这次怎么出的这么简单,偷懒了是吧哈哈哈
A. 简单计算
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
int a,b,c;
cin>>a>>b>>c;
int ans=(c-b)/a*a+b;
cout<<ans<<endl;
}
int main(){
int t=1;
cin>>t;
while(t--){
solve();
}
return 0;
}
B 顶牛
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=110;
bool f[N];
void solve(){
memset(f,false,sizeof f);
int n;
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
int x;
cin>>x;
if(x==1){
f[i]=true;
}
if(x==2){
f[j]=true;
}
if(x==3){
f[i]=f[j]=true;
}
}
}
int ans=0;
for(int i=1;i<=n;i++){
if(!f[i]){
ans++;
}
}
if(ans==0){
cout<<0<<endl;
return ;
}
else{
cout<<ans<<endl;
for(int i=1;i<=n;i++){
if(!f[i]){
cout<<i<<" ";
}
}
}
}
int main(){
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
C程序调用
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
typedef long long ll;
struct node
{
int c,d;
};
node a[N];
ll b[N];
void solve(){
ll n,m,k;
ll c=1;
cin>>n>>m>>k;
for(ll i=1;i<=n;i++){
ll x;
cin>>x;
a[x].c=ceil((double)i/k);
// cout<<a[x].c;
a[x].d=i;
b[i]=x;
}
ll ans=0;
for(ll i=1;i<=m;i++){
ll x;
cin>>x;
// cout<<a[x].c<<endl;
ans+=a[x].c;
ll idx=a[x].d;
if(idx==1){
continue;
}
else{
ll a1=x;
ll a2=b[a[x].d-1];
if(a[a1].c!=a[a2].c){
ll a3=a[a1].c;
ll a4=a[a2].c;
a[a1].c=a4;
a[a2].c=a3;
}
swap(b[a[a1].d],b[a[a2].d]);
a[a1].d-=1;
a[a2].d+=1;
}
}
cout<<ans<<endl;
}
int main(){
int t=1;
while(t--){
solve();
}
return 0;
}
标签:周赛,typedef,cout,int,ll,long,121,solve,Acwing
From: https://www.cnblogs.com/du463/p/17707350.html