目录
A:移动距离
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
int x=233,y=666;
void solve(){
double l=sqrt(x*x+y*y);//斜边长
double q=atan(y*1.0/x); //以x为半径的弧度
double res=l+l*q;
cout<<l<<endl;
cout<<q<<endl;
cout<<res<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
//cin>>T;
while(T--){
solve();
}
return 0;
}
B:客流量上限
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int mod = 1e9+7;
int N =2025;
int qpow(int a,int b){
int res=1;
while(b){
if(b&1) res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
void solve(){
int tmp=qpow(2,N/2);
cout<<tmp<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
//cin>>T;
while(T--){
solve();
}
return 0;
}
C:可分解的正整数
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N = 100010;
int a[N];
void solve(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int res=0;
for(int i=1;i<=n;i++){
if(a[i]==1) continue; //只有1不可分解
res++;
}
cout<<res;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
//cin>>T;
while(T--){
solve();
}
return 0;
}
D:产值调整
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve(){
int a,b,c,k;
cin>>a>>b>>c>>k;
for(int i=1;i<=k;i++){
int tmp=a,num=b;
a=(b+c)/2;
b=(tmp+c)/2;
c=(tmp+num)/2;
if(a==b&&b==c)break;//k循环到一定次数(50--100次),a,b,c就相等了
}
cout<<a<<' '<<b<<' '<<c<<endl;
return ;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
cin>>T;
while(T--){
solve();
}
return 0;
}
/*
2
10 20 30 1
5 5 5 3
*/
E:画展布置
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N = 100010;
int a[N],b[N];
void solve(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
b[i]=a[i]*a[i];
}
sort(b+1,b+n+1);
int l=0,r=0,Min=1e18;//这里要开long long 的最大值,如果开0x3f3f3f(int的最大值)不全对
for(int i=1;i<=n-m+1;i++){
int tmp=b[i+m-1]-b[i];
if(tmp<Min){
l=i;
r=i+m-1;
Min=tmp;
}
}
int res=b[r]-b[l];
cout<<res<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
//cin>>T;
while(T--){
solve();
}
return 0;
}
/*
4 2
1 5 2 4
*/
F:水质检测
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N = 1000010;
char c[2][N];
void solve(){
string a,b;
cin>>a>>b;
int n=a.size();
for(int i=0;i<n;i++){
c[0][i+1]=a[i];
c[1][i+1]=b[i];
}
int l,r; //l第一次出现#的列,r最后一次出现#的列
for(int i=1;i<=n;i++){
if(c[0][i]=='#'||c[1][i]=='#'){
l=i;
break;
}
}
for(int i=n;i>=1;i--){
if(c[0][i]=='#'||c[1][i]=='#'){
r=i;
break;
}
}
int res=0;
for(int i=l;i<=r-1;i++){
if(c[0][i]=='.'&&c[0][i+1]=='#'&&c[1][i]=='#'&&c[1][i+1]=='.'){
res++;
c[1][i+1]='#';
}else if(c[0][i]=='#'&&c[0][i+1]=='.'&&c[1][i]=='.'&&c[1][i+1]=='#'){
res++;
c[0][i+1]='#';
}else if(c[0][i]=='.'&&c[0][i+1]=='.'&&c[1][i]=='#'&&c[1][i+1]=='.'){
res++;
c[1][i+1]='#';
}else if(c[0][i]=='#'&&c[0][i+1]=='.'&&c[1][i]=='.'&&c[1][i+1]=='.'){
res++;
c[0][i+1]='#';
}else if(c[0][i]=='#'&&c[0][i+1]=='.'&&c[1][i]=='#'&&c[1][i+1]=='.'){
if(i<=n-2){
int num=-1;
for(int j=i+1;j<=n;j++){
if(c[0][j]=='#'){
num=0;
break;
}else if(c[1][j]=='#'){
num=1;
break;
}
}
if(num==0){
res++;
c[num][i+1]='#';
}else if(num==1){
res++;
c[num][i+1]='#';
}
}
}
}
cout<<res<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
//cin>>T;
while(T--){
solve();
}
return 0;
}
/*
.##.....#
.#.#.#...
#..#.........
.....#...##.#
#..#.........
.....#..#....
*/