当前位置:网站首页>2020第二届传智杯初赛
2020第二届传智杯初赛
2022-07-28 10:15:00 【小柳学渣】
#include <bits/stdc++.h>
using namespace std;
int n,k;
struct s{
char a;double b,c;
};map<int,int>mp;int p=0;
double a[1001][1001],b[1001],c[1001];
int cc(s aa,s bb)
{
if(aa.c==bb.c)
{
return aa.a<bb.a;
}
return aa.c>bb.c;
}
int main()
{
cin>>n>>k;
s s[1001];
for(int i=0;i<n;i++)
{
cin>>s[i].b>>s[i].a;
}
for(int i=0;i<k;i++)
{
for(int j=0;j<k;j++)
{
cin>>a[i][j];
b[j]+=a[i][j];
}
}
for(int i=0;i<k;i++)
{
b[i]=b[i]/k;
}
for(int i=0;i<k;i++)
{
double r1=0,r2=0;
for(int j=0;j<k;j++)
{
if(fabs(a[j][i]-b[i])<=15)
{
r1+=a[j][i];
r2++;
}
}
c[i]=round(r1/r2);
}
for(int i=0;i<n;i++)
{
s[i].c=round(s[i].b*0.6+c[s[i].a-'A']*0.4);
}
sort(s,s+n,cc);
for(int i=0;i<n;i++)
{
cout<<round(s[i].c)<<" "<<s[i].a<<endl;
}
return 0;
}
#include <bits/stdc++.h>
#define int long long
using namespace std;
int a[1000001],b[1000001];
signed main()
{
int n;
cin>>n;
fill(b,b+n,1);
for(int i=0;i<n;i++)
{
cin>>a[i];
if(i!=0)
{
if(a[i]==a[i-1])b[i]=b[i-1];
if(a[i]>a[i-1])b[i]=b[i-1]+1;
}
}
for(int i=n-2;i>=0;i--)
{
if(a[i]==a[i+1])b[i]=b[i+1];
if(a[i]>a[i+1])b[i]=max(b[i],b[i+1]+1);
}
int r=0;
for(int i=0;i<n;i++)r+=b[i];
cout<<r;
return 0;
}
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
int n;
cin>>n;
map<int,int>m;
while(n--)
{
int x,y;
cin>>x>>y;
m[x]++;
// if(x!=y)m[y]++;//不审题真要命,罚时被罚惨了
if((x^y)!=x)m[(x^y)]++;
}
int ma=-1,maxx=-1;
for(map<int,int>::iterator i=m.begin();i!=m.end();i++)
{
int x=i->first;
int y=i->second;
if(y>ma)
{
maxx=x;
ma=y;
}
}
cout<<maxx;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s,ss;
cin>>s;
for(int i=0;i<s.length();i++)
{
switch(s[i])//不用费脑子
{
case '0':ss+="0000";break;
case '1':ss+="0001";break;
case '2':ss+="0010";break;
case '3':ss+="0011";break;
case '4':ss+="0100";break;
case '5':ss+="0101";break;
case '6':ss+="0110";break;
case '7':ss+="0111";break;
case '8':ss+="1000";break;
case '9':ss+="1001";break;
case 'A':ss+="1010";break;
case 'B':ss+="1011";break;
case 'C':ss+="1100";break;
case 'D':ss+="1101";break;
case 'E':ss+="1110";break;
case 'F':ss+="1111";break;
}
}
while(ss[0]=='0')
{
ss.erase(0,1);
}
if(ss.length()==1)
{
if(ss[0]=='1')cout<<1;
else cout<<0;
return 0;
}
if(ss.length()==2)
{
if(ss[0]=='0'&&ss[1]=='0')cout<<0;
if(ss[0]=='0'&&ss[1]=='1')cout<<"No";
if(ss[0]=='1'&&ss[1]=='0')cout<<"No";
if(ss[0]=='1'&&ss[1]=='1')cout<<1;
return 0;
}
string sss=ss;
int r=0;
for(int i=0;i<ss.length()-1;i++)
{
if(ss[i]=='1')
{
r++;
if(i==0)
{
ss[i]='0';
ss[i+1]=(ss[i+1]=='1'?'0':'1');
}
else if(i==ss.length()-2)
{
ss[i]='0';
ss[i+1]=(ss[i+1]=='1'?'0':'1');
}
else
{
ss[i]='0';
ss[i+1]=(ss[i+1]=='1'?'0':'1');
ss[i+2]=(ss[i+2]=='1'?'0':'1');
}
}
}
int r1=0;
for(int i=0;i<sss.length()-1;i++)
{
if(sss[i]=='1')
{
r1++;
if(i==0)
{
sss[i]='0';
sss[i+1]=(sss[i+1]=='1'?'0':'1');
sss[i+2]=(sss[i+2]=='1'?'0':'1');
}
else if(i==sss.length()-2)
{
sss[i]='0';
sss[i+1]=(sss[i+1]=='1'?'0':'1');
}
else
{
sss[i]='0';
sss[i+1]=(sss[i+1]=='1'?'0':'1');
sss[i+2]=(sss[i+2]=='1'?'0':'1');
}
}
}
for(int i=0;i<ss.length();i++)
{
if(ss[i]=='1')r=-1;
}
for(int i=0;i<sss.length();i++)
{
if(sss[i]=='1')r1=-1;
}
if(r==-1&&r1==-1)cout<<"No"<<endl;
else if(r1==-1)cout<<r;
else if(r==-1)cout<<r1;
else cout<<min(r,r1);
return 0;
}
边栏推荐
- Sleeping barber problem
- What kind of knowledge payment system functions are more conducive to the development of the platform and lecturers?
- ️雄关漫道真如铁,而今迈步从头越️
- 15. Judge whether the target value exists in the two-dimensional array
- [wechat applet] project practice - lottery application
- 管道、管程、管态的区别
- 10 minute quick start EVs [play Huawei cloud]
- 4. Adjust the array order so that odd numbers precede even numbers
- 漏洞分析丨HEVD-0x8.IntegerOverflow[win7x86]
- 数据库mysql基础
猜你喜欢

SQL Server 2016 learning records - connection query

11、链表反转

Performance test of API gateway APIs IX in Google cloud T2a and T2D

初识SuperMap iDesktop

SQL Server 2016学习记录 --- 单表查询

Record a parent-child project in idea, modify the name of project and module, and test it personally!

6、双指针——递增数组两数之和与目标数相等

15. Judge whether the target value exists in the two-dimensional array

django-celery-redis异步发邮件

SQL Server 2016 学习记录 --- 嵌套查询
随机推荐
PHP生成二维码(学习)
Bitwise and, or, XOR and other operation methods
Talk about the problem of preventing others from debugging websites through console based on JS implementation
Uni app advanced life cycle
Match file names from file paths using regular expressions
Detailed explanation of thread synchronization volatile and synchronized
7. Dichotomy -- find a set of repeated or ordered but rotating arrays
Step 4 - user development environment settings
SQL Server 2016 学习记录 --- 数据更新
3. Print the linked list in reverse order with the array
Xu Ziyang, President of ZTE: 5nm chip will be launched in 2021
Record a parent-child project in idea, modify the name of project and module, and test it personally!
PHP generates QR code (learning)
按位与、或、异或等运算方法
SuperMap iserver publishing management and calling map services
15. Judge whether the target value exists in the two-dimensional array
ogg参数filter的使用问题【急】
SQL Server 2016学习记录 --- 单表查询
SQL Server 2016 学习记录 --- 集合查询
a different object with the same identifier value was already associated with the session