博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2017ACM/ICPC广西邀请赛
阅读量:6976 次
发布时间:2019-06-27

本文共 6127 字,大约阅读时间需要 20 分钟。

 

You are given a positive integer n, please count how many positive integers k satisfy 
kknkk≤n. 

InputThere are no more than 50 test cases. 

Each case only contains a positivse integer n in a line. 
1n10181≤n≤1018 
OutputFor each test case, output an integer indicates the number of positive integers k satisfy kknkk≤n in a line.Sample Input

14

Sample Output

12

A是最好做的,找到那个最大的数,15吧

写快速幂只是不想循环,感觉也很麻烦

#include
using namespace std;typedef long long ll;ll la(int n){ ll ans=1,base=n; while(n) { if(n&1)ans=ans*base; n>>=1,base=base*base; } return ans;}int main(){ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); ll n; while(cin>>n) { int i; for(i=1;i<16;i++) if(la(i)>n)break; cout<
<<"\n"; } return 0;}

 

Little A has come to college and majored in Computer and Science. 
Today he has learned bit-operations in Algorithm Lessons, and he got a problem as homework. 
Here is the problem: 
You are giving n non-negative integers 
a1,a2,,ana1,a2,⋯,an, and some queries. 
A query only contains a positive integer p, which means you 
are asked to answer the result of bit-operations (and, or, xor) of all the integers except apap. 

InputThere are no more than 15 test cases. 

Each test case begins with two positive integers n and p 
in a line, indicate the number of positive integers and the number of queries. 
2n,q1052≤n,q≤105 
Then n non-negative integers a1,a2,,ana1,a2,⋯,an follows in a line, 0ai1090≤ai≤109 for each i in range[1,n]. 
After that there are q positive integers p1,p2,,pqp1,p2,⋯,pqin q lines, 1pin1≤pi≤n for each i in range[1,q].
OutputFor each query p, output three non-negative integers indicates the result of bit-operations(and, or, xor) of all non-negative integers except apap in a line. 
Sample Input

3 31 1 1123

Sample Output

1 1 01 1 01 1 0

让你求n个数除x这个数的按位与和按位或还有异或和,明明前缀后缀最方便,sb写了一个统计二进制位的

#include
using namespace std;typedef long long ll;const int N=1e5+5;int a[N],num[31],f[31];int la(int n){ int i=0; while(n) { if(n&1)num[i]++; n>>=1,i++; }}int main(){ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); int n,q; while(cin>>n>>q) { int xor1=0; memset(num,0,sizeof num); for(int i=0; i
>a[i],xor1^=a[i]; for(int i=0; i
>x; x--; for(int i=0; i<31; i++) f[i]=num[i]; int i=0; int t=a[x]; while(t) { if(t&1)f[i]--; t>>=1,i++; } int and1=0,or1=0; for(int i=30;i>=0;i--) { and1=and1*2+(f[i]==n-1); or1=or1*2+(f[i]!=0); } cout<
<<" "<
<<" "<<(xor1^a[x])<<"\n"; } } return 0;}

 

Nike likes playing cards and makes a problem of it. 
Now give you n integers, 
ai(1in)ai(1≤i≤n) 
We define two identical numbers (eg: 2,22,2) a Duizi, 
and three consecutive positive integers (eg: 2,3,42,3,4) a Shunzi. 
Now you want to use these integers to form Shunzi and Duizi as many as possible. 
Let s be the total number of the Shunzi and the Duizi you formed. 
Try to calculate max(s)max(s). 
Each number can be used only once. 

InputThe input contains several test cases. 

For each test case, the first line contains one integer n(1n1061≤n≤106). 
Then the next line contains n space-separated integers aiai (1ain1≤ai≤n) 
OutputFor each test case, output the answer in a line. 
Sample Input

71 2 3 4 5 6 791 1 1 2 2 2 3 3 362 2 3 3 3 3 61 2 3 3 4 5

Sample Output

2432

Hint

Case 1(1,2,3)(4,5,6)Case 2(1,2,3)(1,1)(2,2)(3,3)Case 3(2,2)(3,3)(3,3)Case 4(1,2,3)(3,4,5)

贪心组对子和顺子就好了

#include
using namespace std;int n,x,a[1000005];int main(){ while(scanf("%d",&n)!=EOF) { memset(a,0,sizeof a); int sum=0; for(int i=0;i

我是只考虑第一张的

#include 
#include
const int N=1e5+5;int a[N];int main(){ int n; while(~scanf("%d",&n)) { memset(a,0,sizeof(int)*(n+5)); for(int i=0; i

 

Bob's school has a big playground, boys and girls always play games here after school. 
To protect boys and girls from getting hurt when playing happily on the playground, rich boy Bob decided to cover the playground using his carpets. 
Meanwhile, Bob is a mean boy, so he acquired that his carpets can not overlap one cell twice or more. 
He has infinite carpets with sizes of 
1×21×2 and 2×12×1, and the size of the playground is 4×n4×n. 
Can you tell Bob the total number of schemes where the carpets can cover the playground completely without overlapping? 

InputThere are no more than 5000 test cases. 

Each test case only contains one positive integer n in a line. 
1n10181≤n≤1018 
OutputFor each test cases, output the answer mod 1000000007 in a line. 
Sample Input

12

Sample Output

15

暴力算几项,肯定是前四项推出来第五项的,

暴力跑一下

然后暴力猜系数,

#include
using namespace std;typedef long long ll;const int MD=1e9+7;int A[5]={
0,1,5,11,36};struct Matrix{ ll a[4][4]; Matrix() { memset(a,0,sizeof(a)); } Matrix operator*(const Matrix y) { Matrix ans; for(int i=0; i<4; i++) for(int j=0; j<4; j++) for(int k=0; k<4; k++) ans.a[i][j]=(ans.a[i][j]+a[i][k]*y.a[k][j]+MD)%MD; return ans; } void operator=(const Matrix b) { for(int i=0; i<4; i++) for(int j=0; j<4; j++) a[i][j]=b.a[i][j]; }};ll la(ll x){ Matrix ans,t; t.a[0][0]=t.a[0][1]=t.a[1][2]=t.a[2][3]=t.a[2][0]=1; t.a[3][0]=-1,t.a[1][0]=5; ans.a[0][0]=36,ans.a[0][1]=11,ans.a[0][2]=5,ans.a[0][3]=1; while(x) { if(x&1)ans=ans*t; t=t*t; x>>=1; } return ans.a[0][0];}int main(){ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); ll n; while(cin>>n) { if(n<5)cout<
<<"\n"; else cout<
<<"\n"; } return 0 ;}

 

转载于:https://www.cnblogs.com/BobHuang/p/8805066.html

你可能感兴趣的文章
学习javascript过程中的心得体会
查看>>
分布式文件系统之FastDFS
查看>>
Basic Tutorials of Redis(7) -Publish and Subscribe
查看>>
谈谈Circuit Breaker在.NET Core中的简单应用
查看>>
PyCharm IDE环境搭建
查看>>
HADOOP之PiG简介
查看>>
2017 多校6 String
查看>>
influxdb与传统数据库的比较
查看>>
滚动字幕
查看>>
Centos目录结构详细版
查看>>
MySQL 如何执行关联查询
查看>>
从硬币游戏学习敏捷开发
查看>>
2017 4月14日
查看>>
KMP
查看>>
CefSharp .net
查看>>
java中关于null的一些理解
查看>>
sqlite3中的数据类型
查看>>
1.26-CAD异形封装的制作
查看>>
android ImageLoader加载本地图片的工具类
查看>>
安全的发布 .NET 应用的改动到产品服务器环境
查看>>