2017ACM/ICPC广西邀请赛-重现赛(感谢广西大学)

A Math Problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

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

Input

There are no more than 50 test cases.

Each case only contains a positivse integer n in a line.

1≤n≤1018

Output

For each test case, output an integer indicates the number of positive integers k satisfy kk≤n in a line.

Sample Input

1
4

Sample Output

1
2

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=437893890380859375;
int main()
{
    ll n;
    while(~scanf("%lld",&n))
    {
        if(n>=N)
            printf("15\n");
        else
        {
            for(int k=1; k<16; k++)
            {
                ll s=1;
                for(int i=0; i<k; i++)
                    s*=k;
                if(s>n)
                {
                    printf("%d\n",k-1);
                    break;
                }
            }
        }
    }
    return 0;
}

Covering

Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

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×2 and 2×1, and the size of the playground is 4×n.

Can you tell Bob the total number of schemes where the carpets can cover the playground completely without overlapping?

Input

There are no more than 5000 test cases.

Each test case only contains one positive integer n in a line.

1≤n≤1018

Output

For each test cases, output the answer mod 1000000007 in a line.

Sample Input

1
2

Sample Output

1
5

#include <stdio.h>
#include <string.h>
const int MD=1e9+7;
typedef long long LL;
struct matrix
{
    LL mat[5][5];
};
matrix matmul(matrix a,matrix b,int n)
{
    int i,j,k;
    matrix c;
    memset(c.mat,0,sizeof(c.mat));
    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            for(k=0; k<n; k++)
            {
                c.mat[i][j]=(c.mat[i][j]+a.mat[i][k]*b.mat[k][j])%MD;
            }
        }
    }
    return c;
}
matrix matpow(matrix a,LL k,int n)
{
    matrix b;
    int i;
    memset(b.mat,0,sizeof(b.mat));
    for(i=0; i<n; i++) b.mat[i][i]=1;
    while(k)
    {
        if(k&1) b=matmul(a,b,n);
        a=matmul(a,a,n);
        k>>=1;
    }
    return b;
}
int main()
{
    LL k;
    matrix a,b;
    memset(a.mat,0,sizeof(a.mat));
    memset(b.mat,0,sizeof(b.mat));
    a.mat[0][0]=1,a.mat[2][0]=1,a.mat[3][0]=1;
    b.mat[0][0]=1,b.mat[0][1]=5,b.mat[0][2]=1,b.mat[0][3]=-1;
    b.mat[1][0]=1,b.mat[2][1]=1,b.mat[3][2]=1;
    while(~scanf("%lld",&k))
    {
        printf("%lld\n",(matmul(matpow(b,k,4),a,4).mat[0][0]+MD)%MD);
    }
    return 0;
}

CS Course

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

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,?,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 ap.

Input

There 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.

2≤n,q≤105

Then n non-negative integers a1,a2,?,an follows in a line, 0≤ai≤109 for each i in range[1,n].

After that there are q positive integers p1,p2,?,pqin q lines, 1≤pi≤n for each i in range[1,q].

Output

For each query p, output three non-negative integers indicates the result of bit-operations(and, or, xor) of all non-negative integers except ap in a line.

Sample Input

3 3
1 1 1
1
2
3

Sample Output

1 1 0
1 1 0
1 1 0

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int a[N],b[N];
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        memset(b,0,sizeof(b));
        int Xor=0,And=0xffffffff,Or=0;
        for(int i=1; i<=n; i++)
        {
            int x;
            scanf("%d",&x);
            a[i]=x;
            And&=x;
            Or|=x;
            Xor^=x;
            for(int j=0; x; j++,x>>=1)
                b[j]+=x%2;
        }
        while(m--)
        {
            int q;
            scanf("%d",&q);
            q=a[q];
            int A=And,O=Or,X=Xor;
            X=X^q;
            for(int j=0; j<=30; j++,q>>=1)
            {
                if(b[j]==n-1&&q%2==0)A+=(1<<j);
                if(b[j]==1&&q%2)O-=(1<<j);
            }
            printf("%d %d %d\n",A,O,X);
        }
    }
    return 0
时间: 2024-11-03 20:49:37

2017ACM/ICPC广西邀请赛-重现赛(感谢广西大学)的相关文章

2017 ICPC 广西邀请赛1004 Covering

Covering Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 187    Accepted Submission(s): 107 Problem Description Bob's school has a big playground, boys and girls always play games here after sch

2017 ACM/ICPC 广西邀请赛 题解

题目链接  Problems HDOJ上的题目顺序可能和现场比赛的题目顺序不一样, 我这里的是按照HDOJ的题目顺序来写的. Problem 1001 签到 #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i) typedef long long LL; LL n, f[31]; int ans; int main(){ f[1] = 1LL; fo

2014ACM/ICPC亚洲区北京站-重现赛 [B.Black And White] 涂色DFS

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5113 题目大意:在一个N * M的棋盘里涂色,要求i颜色要涂ci次.ci求和为N * M. 关键思想:从第一个点开始着色,一行一行涂,注意一旦找到答案后面就不必搜,当剩下个数为n时若有种颜色>n/2上取整就不必搜了(!). #include <iostream> #include <iomanip> #include <cstdio> #include <cst

2017 ICPC 广西邀请赛1005 CS Course

CS Course Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description Little A has come to college and majored in Computer and Science. Today he has learne

2015ACM/ICPC亚洲区长春站-重现赛 1006 Almost Sorted Array

Problem Description: We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is an overkill to use these algorithms for an almost sorted array. We say an array

HDU 5112 A Curious Matt (2014ACM/ICPC亚洲区北京站-重现赛)

A Curious Matt Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 3058    Accepted Submission(s): 1716 Problem Description There is a curious man called Matt. One day, Matt's best friend Ted is w

2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)HDU6225.Little Boxes-大数加法

整理代码... Little Boxes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2304    Accepted Submission(s): 818 Problem Description Little boxes on the hillside.Little boxes made of ticky-tacky.Littl

hdu5512 Pagodas(2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学) )

Pagodas Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 14 Accepted Submission(s): 13 Problem Description n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai M

2017 acm / icpc shenyang 双十一单身狗温馨重现赛

上午做实验老师看错时间来晚了,20与非门一侧坏掉..于是做完实验就,光荣迟到了!!!QAQ... 一开始..看B题...喵喵喵??? J题...窝只会暴力..算了算了.. 刷新~ I题AC ratio 好像还可以!戳进去一看,a+b+c+d...一克斯Q斯咪?哭叽叽写了个大数加法,piapiapia乱敲一气竟然没崩,AC~~~是个好开头吖有木有~o(* ̄▽ ̄*)ブ~ K题就是小兔子跳啊跳~piapiapia求和然后选择一下从哪一端起跳,紫欣sama1A~ L题一开始对题意有误解,看懂样例之后就发