D. A Leapfrog in the Array Codeforces Round #469 (Div. 2)

原创 2018年04月16日 12:35:21

题目链接:http://codeforces.com/contest/950/problem/D
参考链接:https://blog.csdn.net/xiangAccepted/article/details/79506332
所得:我原本是找单个样例的规律,但是找出来后发现还是会超时,看了上面的参考链接后发现,原来最省事的规律是在一系列样例之间找规律

#include <bits/stdc++.h>
#define pi acos(-1)
#define fastcin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL ll_INF = 0x3f3f3f3f3f3f3f3f;//4e18 ~= 2^62
const int maxn =10000 + 10;
const LL mod = 1e9+7;




int main()
{
    LL n, p, loc;
    scanf("%I64d%I64d", &n, &p);
    while(p--){
        scanf("%I64d", &loc);
        if(loc&1) printf("%I64d\n", (loc+1)/2);
        else{
            LL ceng = n;
            while(!(loc&1)){
                loc = ceng - loc/2;
                ceng = loc;
            }
            printf("%I64d\n", n-ceng+(loc+1)/2);
        }
    }
}

Codeforces Round #327 (div.2)(A B C D)

codeforces round #327 (div.2)
  • lincifer
  • lincifer
  • 2015-10-26 13:11:58
  • 1198

Codeforces Round #258 (Div. 2)-(A,B,C,D,E)

A:Game With Sticks 水题。。。每次操作,都会拿走一个横行,一个竖行。 所以一共会操作min(横行,竖行)次。 #include #include #include #include ...
  • rowanhaoa
  • rowanhaoa
  • 2014-07-25 14:39:48
  • 1551

Educational Codeforces Round 34 (Rated for Div. 2) D

D. Almost Difference time limit per test 2 seconds memory limit per test 256 megabytes ...
  • ACM_e
  • ACM_e
  • 2017-12-14 13:44:15
  • 142

Codeforces Round #444 (Div. 2)-贪心&尺取-Ratings and Reality Shows

http://codeforces.com/contest/887/problem/D 一个模特有两种活动。 ① 拍照片,挣钱 a。 ②开演唱会,花费b 给定模特这两种工作的时间表。 模特可以...
  • qq_35781950
  • qq_35781950
  • 2017-11-11 20:11:11
  • 210

Educational Codeforces Round 38 (Rated for Div. 2) B. Run For Your Prize

B. Run For Your PrizeYou and your friend are participating in a TV show &quot;Run For Your Prize&quo...
  • s540239976
  • s540239976
  • 2018-02-17 13:35:37
  • 214

Codeforces Round #464 (Div. 2) B. Hamster Farm

B. Hamster FarmDima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them ...
  • s540239976
  • s540239976
  • 2018-02-18 12:28:34
  • 222

Codeforces Round #446 (Div. 2) D. Gluttony

传送门:http://codeforces.com/contest/892/problem/D 题意是: 给你一个a[]数组,让你构造出一个b[]数组,使得a[]数组的前k项子集和,和b[...
  • Pandauncle
  • Pandauncle
  • 2017-11-18 21:07:25
  • 191

Codeforces Round #426 (Div. 2) D. The Bakery(DP+线段树)

Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredient...
  • SSimpLe_Y
  • SSimpLe_Y
  • 2017-07-31 09:16:44
  • 1166

ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined) E. Team Work

题意 求出∑i=1nCin∗ik∑i=1nCni∗ik\sum_{i=1}^{n}C_n^i*i^k 题解 不错的题啊 比赛的时候没有做出来 主要是我不会斯特林推式子 那就用垃圾一点的...
  • qq_36797743
  • qq_36797743
  • 2018-02-17 16:09:23
  • 140
收藏助手
不良信息举报
您举报文章:D. A Leapfrog in the Array Codeforces Round #469 (Div. 2)
举报原因:
原因补充:

(最多只允许输入30个字)