Codeforces Round #383 (Div. 2)(A+B)
来源:互联网 发布:零售药店软件 编辑:程序博客网 时间:2024/05/18 00:53
A: 题意:求解1378^n的个位数为几?
题解:快速幂裸题
代码:
#include<bits/stdc++.h>#define ll long longusing namespace std;ll quick(ll x,ll y){ ll ans=1; while(y) { if(y&1) ans=ans*x%10; x=x*x%10; y>>=1; } return ans%10;}int main(){ ll n; cin>>n; cout<<quick(8,n)<<endl;}
B:题意:给出n个数和k,问异或为k的组数。
题解:a异或b=c,推出b异或c=a,map计数,注意k为0的情况。
代码:
#include<bits/stdc++.h>#define ll long longusing namespace std;map<ll,ll>mp;ll a[1000006];int main(){ int n,x; mp.clear(); scanf("%d%d",&n,&x); bool p=false; if(x==0) p=true; for(int i=0;i<n;i++) { scanf("%d",&a[i]); mp[a[i]]++; } ll ans=0; for(int i=0;i<n;i++) { int tmp=a[i]^x; if(mp[tmp]) { if(p) ans+=mp[tmp]-1; else ans+=mp[tmp]; } } printf("%lld\n",ans/2);}
0 0
- Codeforces Round #383 (Div. 2)(A+B)
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #216 (Div. 2) A.B
- Codeforces round #236Div.2--A;B
- Codeforces Round #236 (Div. 2)------A,B
- Codeforces Round #237 (Div. 2) A & B
- Codeforces Round #247 (Div. 2) A B
- Codeforces Round #251 (Div. 2) A~B
- Codeforces Round #249 (Div. 2) A B
- Codeforces Round #271 (Div. 2)-A.B
- Codeforces Round #202 (Div. 2) A,B
- Codeforces Round #277 (Div. 2) A B
- Codeforces Round #278 (Div. 2) A B
- Codeforces Round #278 (Div. 2) A, B
- Codeforces Round #281 (Div. 2) A B
- Codeforces Round #283 (Div. 2) A B
- Codeforces Round #282 (Div. 2) A B
- Oracle SQL 查询排序
- POSIX 线程编程指南(一)
- 存储过程实现可扩展灵活接口
- js-计算保留小数点一两位并避免出现无限小数的bug
- android BroadcastReceiver广播使用详解
- Codeforces Round #383 (Div. 2)(A+B)
- SpringMVC-REST设计风格
- JS--轻松设置获取表单数据
- 蛇形填数
- HashSet的故事----Jdk源码解读
- java字符串的比较总结
- JAVA学习之-数据库设计及优化_课堂笔记
- 让一个块级元素在某区域内上下左右居中
- 信号量 哲学家进餐问题