当前位置:网站首页>SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
2022-07-03 15:56:00 【Unwilling to make salted fish】
A
The question :n Coins in a circle , Each round can take away one or two adjacent coins , Finally, the player who takes all the coins wins .Alice First of all , Ask who will win .
Ideas : When n<=2 when ,Alice You can take it all at once ,Alice A winning ; When n>=3 when , No matter what Alice take 1 or 2 individual ,Bob You can take coins according to the parity of the remaining coins , Cause to give Alice The number of coins left is even , thereafter ,Bob Just imitate Alice Take the coin ,Bob A winning .( Symmetric game )
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <cstdlib>
#include <set>
#include <queue>
#define lowbit(x) x&(-x)
#define endl '\n'
#define sf(x) scanf("%d",&x)
#define rep(i,x) for(i=0;i<(x);i++)
#define gao(x) cerr<<#x<<"->"<<x<<endl
#define gen(x) x##_
typedef long long ll;
const int maxx=1e6+10;
using namespace std;
void solve()
{
int n;
while(cin>>n&&n)
{
if(n<=2) cout<<"Alice\n";
else cout<<"Bob\n";
}
}
int main()
{
int _t=1;
//scanf("%d",&_t);
while(_t--)
{
solve();
}
system("pause");
}
D
The question : Here you are. n An element of r Array ,m An element of b Array , Without changing the relative position of the two array elements, it is merged into a Array , seek f(a) The maximum of
Ideas : requirement a The maximum prefix sum of the array , because b and r The order of the array is independent , So we only need b The maximum prefix sum of the array plus r The maximum prefix sum of the array is the answer .
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <cstdlib>
#include <set>
#include <queue>
#define lowbit(x) x&(-x)
#define endl '\n'
#define sf(x) scanf("%d",&x)
#define rep(i,x) for(i=0;i<(x);i++)
#define gao(x) cerr<<#x<<"->"<<x<<endl
#define gen(x) x##_
typedef long long ll;
const int maxx=110;
const int inf=0x3f3f3f3f;
using namespace std;
ll n,m;
ll a[maxx],b[maxx];
void solve()
{
scanf("%lld",&n);
ll maxa=0,maxb=0;
ll suma=0,sumb=0;
for(int i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
suma+=a[i];
if(suma>maxa) maxa=suma;
}
scanf("%lld",&m);
for(int i=1;i<=m;i++)
{
scanf("%lld",&b[i]);
sumb+=b[i];
if(sumb>maxb) maxb=sumb;
}
printf("%lld\n",maxa+maxb);
}
int main()
{
int _t=1;
scanf("%d",&_t);
while(_t--)
{
solve();
}
system("pause");
}
F
The question :
Ideas : Find the maximum XOR value of two numbers , Because XOR is No carry Addition of , It must be more A number of ( Note that not the biggest ) XOR with another number with the largest number of different bits under the binary . So take it out first The maximum number of binary digits The number of , Enumerate these numbers , XOR with other numbers , Keep taking the maximum .
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <cstdlib>
#include <set>
#include <queue>
#define lowbit(x) x&(-x)
#define endl '\n'
#define sf(x) scanf("%d",&x)
#define rep(i,x) for(i=0;i<(x);i++)
#define gao(x) cerr<<#x<<"->"<<x<<endl
#define gen(x) x##_
typedef long long ll;
const int maxx=1e5+10;
const double PI=acos(-1);
const int inf=0x3f3f3f3f;
using namespace std;
int n;
ll a[maxx];
ll op[maxx];
ll ppow(ll n,ll m)
{
ll ret=1;
for(ll i=1;i<=m;i++)
{
ret*=n;
}
return ret;
}
void solve()
{
scanf("%d",&n);
ll ma=-inf;
for(int i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
if(a[i]>ma) ma=a[i];// Take the maximum
}
ll ans=-inf;
int x=1.0*log(ma)/log(2);//x Is the number of bits of the maximum value under binary x=log 2 ma Rounding down
ll tem=ppow(2,x);//tem by x Minimum value under bit binary
int cnt=0;
for(int i=1;i<=n;i++)// Take out the maximum number of binary digits
{
if(a[i]>=tem)// Take out the maximum number of binary digits
{
op[++cnt]=a[i];
}
}
for(int i=1;i<=cnt;i++)// Enumerate the maximum number of binary digits
{
for(int j=1;j<=n;j++)// enumeration a[j]
{
ll ret=op[i]^a[j];
if(ret>ans) ans=ret;
}
}
printf("%lld",ans);
}
int main()
{
int _t=1;
//scanf("%d",&_t);
while(_t--)
{
solve();
}
system("pause");
}
I
The question : Give you one containing ( and ), For the other ? String , among ? Can be replaced by ( or ), Ask if you can make a legal sequence .
Ideas : First, the length of the string must be even , Second, just guarantee ) Not in the first place ,( Not at the end .
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <cstdlib>
#include <set>
#include <queue>
#define lowbit(x) x&(-x)
#define endl '\n'
#define sf(x) scanf("%d",&x)
#define rep(i,x) for(i=0;i<(x);i++)
#define gao(x) cerr<<#x<<"->"<<x<<endl
#define gen(x) x##_
typedef long long ll;
const int maxx=1e6+10;
using namespace std;
char s[110];
void solve()
{
scanf("%s",s+1);
int len=strlen(s+1);
if(len&1)
{
printf("NO\n");
return ;
}
if(s[1]==')'||s[len]=='(') printf("NO\n");
else printf("YES\n");
}
int main()
{
int _t=1;
scanf("%d",&_t);
while(_t--)
{
solve();
}
system("pause");
}
L
The question : Give you the length of the hour hand and minute hand a,b, after h Hours ,m Minutes later , Find the length of the connecting line at the end of the hour hand and minute hand .
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <cstdlib>
#include <set>
#include <queue>
#define lowbit(x) x&(-x)
#define endl '\n'
#define sf(x) scanf("%d",&x)
#define rep(i,x) for(i=0;i<(x);i++)
#define gao(x) cerr<<#x<<"->"<<x<<endl
#define gen(x) x##_
typedef long long ll;
const int maxx=110;
const double PI=acos(-1);
const int inf=0x3f3f3f3f;
using namespace std;
ll la,lb,h,m;
void solve()
{
scanf("%lld %lld %lld %lld",&la,&lb,&h,&m);
ll ta=0,tb=0;//min
ta=h*60+m,tb=m;// Clockwise movement time , Minute hand movement time
double ang=(double)abs(12*tb-ta)/360.0;
ang*=PI;// The angle of the two needles
printf("%.20f",sqrt(la*la+lb*lb-2*la*lb*cos(ang)));//a*a+b*b-c*c=2*a*b*cosC
}
int main()
{
int _t=1;
//scanf("%d",&_t);
while(_t--)
{
solve();
}
system("pause");
}
边栏推荐
- 【Proteus仿真】74HC595+74LS154驱动显示16X16点阵
- Seckill system 3- product list and product details
- [200 opencv routines] 217 Mouse interaction to obtain polygon area (ROI)
- 请做好3年内随时失业的准备?
- 详解指针进阶2
- 如何使用 @NotNull等注解校验 并全局异常处理
- UnityShader——MaterialCapture材质捕捉效果 (翡翠斧头)
- Microservice API gateway zuul
- Go language self-study series | golang switch statement
- Popular understanding of gradient descent
猜你喜欢
App移动端测试【3】ADB命令
MB10M-ASEMI整流桥MB10M
Salary 3000, monthly income 40000 by "video editing": people who can make money never rely on hard work!
Microservices - load balancing ribbon
App mobile terminal test [3] ADB command
How are integer and floating-point types stored in memory
Seckill system 2 redis solves the problem of distributed session
Detailed explanation of string function and string function with unlimited length
Popular understanding of random forest
秒杀系统2-Redis解决分布式Session问题
随机推荐
nifi从入门到实战(保姆级教程)——flow
The difference between RAR and zip files
Distributed task scheduling XXL job
QT use qzxing to generate QR code
Function introduction of JMeter thread group
突破100万,剑指200万!
找映射关系
Visual host system design and development (Halcon WinForm)
The wonderful use of do{}while()
Go语言自学系列 | golang中的if else语句
String functions that you need to know
Popular understanding of linear regression (I)
详解指针进阶2
使用AUR下载并安装常用程序
Tensorflow realizes verification code recognition (III)
Go language self-study series | golang switch statement
Calibre LVL
"Remake Apple product UI with Android" (3) - elegant statistical chart
Win32 create window and button (lightweight)
Redis high availability and persistence